Hello, I'm trying to open a dialog with a selectonemenu, depending on what the user selects. My SelectOneMenu is like this
<p:column headerText="Mecânica">
<h:commandButton>
<h:selectOneMenu value="#{bancoPerguntasMBean.mecanica}"
id="mecanica" onchange="PF('cadastraMecanica').show();"
rendered="#{document.type == 'Pergunta'}">
<f:selectItem itemLabel="Selecione a mecânica"
noSelectionOption="true" />
<f:selectItems value="#{bancoPerguntasMBean.mecanicas}" />
</h:selectOneMenu>
</h:commandButton>
</p:column>
And my dialogue is like this
<h:form id="cadastraMecanica">
<p:dialog style="text-align: center" header="Cadastrar Mecânica"
widgetVar="cadastraMecanica" resizable="false" modal="true"
width="1050" height="630">
<p:outputPanel rendered="#{bancoPerguntasMBean.mecanica == 'QUIZ'}">
<ui:include src="bancoPerguntasQuestaoQuiz.xhtml" />
</p:outputPanel>
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanica == 'VERDADEIROFALSO'}">
<ui:include src="bancoPerguntasQuestaoVerdadeiroFalso.xhtml" />
</p:outputPanel>
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanica == 'DESCRITIVA'}">
<ui:include src="bancoPerguntasQuestaoDescritiva.xhtml" />
</p:outputPanel>
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanica == 'ASSOCIACAO'}">
<ui:include src="bancoPerguntasQuestaoAssociacao.xhtml" />
</p:outputPanel>
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanica == 'ARRASTASOLTA'}">
<ui:include src="bancoPerguntasQuestaoArrastaSolta.xhtml" />
</p:outputPanel>
</p:dialog>
</h:form>
My question is how to correctly open the dialog, with the correct include of the file. Notice that depending on what is selected it makes a different include, but I am not able to retrieve the value selected by the user to do the validation in the dialog. Someone to give a help?
Updating
I have refactored the code to try to open the correct include, but without success, it follows refactoring
<p:column headerText="Mecânica" style="text-align: center">
<p:selectOneMenu id="mecanicas"
value="#{bancoPerguntasMBean.mecanicaSelecionada}"
required="true" widgetVar="sel"
onchange="PF('modalMecanica').show(); getMecanicaSelecionada()"
rendered="#{document.type == 'Pergunta'}">
<f:selectItem itemLabel="Selecione a mecânica" itemValue=""
noSelectionOption="true" />
<f:selectItems value="#{bancoPerguntasMBean.mecanicas}"
var="mecanica" id="mecanica" itemValue="#{mecanica.nome}"
rendered="#{mecanica.nome != 'IMAGEM RESPOSTA'}"
itemLabel="#{mecanica.nome}" />
</p:selectOneMenu>
</p:column>
Here the dialog
<h:form id="modalMecanica">
<p:dialog style="text-align: center" header="Cadastrar Mecânica"
widgetVar="modalMecanica" resizable="false" modal="true"
width="1050" height="630">
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanicaSelecionada == 'QUIZ'}">
<ui:include src="bancoPerguntasQuestaoQuiz.xhtml" />
</p:outputPanel>
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanicaSelecionada == 'VERDADEIRO FALSO'}">
<ui:include src="bancoPerguntasQuestaoVerdadeiroFalso.xhtml" />
</p:outputPanel>
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanicaSelecionada == 'DESCRITIVA'}">
<ui:include src="bancoPerguntasQuestaoDescritiva.xhtml" />
</p:outputPanel>
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanicaSelecionada == 'ASSOCIACAO'}">
<ui:include src="bancoPerguntasQuestaoAssociacao.xhtml" />
</p:outputPanel>
<p:outputPanel
rendered="#{bancoPerguntasMBean.mecanicaSelecionada == 'ARRASTA SOLTA'}">
<ui:include src="bancoPerguntasQuestaoArrastaSolta.xhtml" />
</p:outputPanel>
</p:dialog>
</h:form>
The dialog opens correctly, however empty, it is not performing any include. In the bean I created an attribute that receives the selected face
private String mecanicaSelecionada;