How to change/redirect togglePanelItem thru server side
felipeleite Oct 16, 2012 4:31 PMHi, I have a rich:popupPanel with 2 rich:togglePanelItem so far.
I'd like to validate each step on server side and depends of the result go to next step or stay on the current one.
I've tried many ways to do that but always I go to second step no matter whats happen.
Thnaks in advance
My code is:
main.xhtml
<rich:popupPanel header="Editar Consulta" id="editPane" domElementAttachment="parent" autosized="true"> <rich:togglePanel id="wizardPanel" switchType="ajax" onitemchange="return validarPasso();" itemChangeListener="#{consultaManageBean.criarConsulta}"> <rich:togglePanelItem id="passo1"> <ui:include src="/consulta/criarPasso1.xhtml" /> </rich:togglePanelItem> <rich:togglePanelItem id="passo2"> <ui:include src="/consulta/criarPasso2.xhtml" /> </rich:togglePanelItem> </rich:togglePanel> </rich:popupPanel>
criarPasso1.xhtml
<div style="position:relative;height:140px"> <h:inputHidden id="passoCorrente" value="#{consultaManageBean.passoCorrente}"/> <h:panelGrid id="editGrid" columns="2"> <h:outputText value="Assunto:"/> <rich:select id="idAssunto" required="true" value="#{consultaManageBean.editedItem.assunto.idAssunto}" requiredMessage="Campo [Assunto] Obrigatorio" > <f:selectItems value="#{assuntoManageBean.lstAssunto}" var="assunto" itemValue="#{assunto.idAssunto}" itemLabel="#{assunto.nome}" /> </rich:select> <h:outputText value="Sistema:" /> <rich:select id="idSistema" value="#{consultaManageBean.editedItem.sistema.idSistema}" required="true" requiredMessage="Campo [Sistema] Obrigatorio"> <f:selectItems value="#{sistemaManageBean.lstSistema}" var="sistema" itemValue="#{sistema.idSistema}" itemLabel="#{sistema.nome}" /> </rich:select> <h:outputText value="Nome:" /> <h:inputText value="#{consultaManageBean.editedItem.nome}" required="true" requiredMessage="Campo [Nome] Obrigatorio" id="nome" size="40" maxlength="70" /> <h:outputText value="Descricao:" /> <h:inputTextarea value="#{consultaManageBean.editedItem.descricao}" id="descricao" cols="37" rows="3" required="true" requiredMessage="Campo [Descricao] Obrigatorio" /> <h:outputText value="Consulta SQL:" /> <h:inputTextarea value="#{consultaManageBean.editedItem.consultaSql}" id="consultaSql" cols="100" rows="6" required="true" requiredMessage="Campo [Consulta SQL] Obrigatorio" /> <h:outputText value="Tabelas Envolvidas:" /> <h:inputTextarea value="#{consultaManageBean.editedItem.tabelasEnvolvidas}" id="tabelasEnvolvidas" cols="100" rows="6" required="true" requiredMessage="Campo [Tabelas Envolvidas] Obrigatorio" /> <h:panelGroup /> Obs: Separe o nome das tabelas envolvidas por ponto e virgula. </h:panelGrid> <a4j:commandButton style="float:right" value="Teste" oncomplete="#{rich:component('wizardPanel')}.switchToItem('passo2'); return false;"/> <div class="navPanel" style="width: 100%;"> <a4j:commandButton style="float:right" value="Proximo >>"> <rich:toggleControl targetItem="@next" event="click" /> </a4j:commandButton> </div> </div>
ConsultaManageBean.java
.... public String criarConsulta(ItemChangeEvent e) { String outcome = ""; if (passoCorrente == 1) { // do something for the first step. If is OK go to step two outcome = "criarPasso2"; // else stay on the first step to fix some problem. outcome = "criarPasso1"; } return outcome; // outcome } ....