jsf - PrimeFaces wizard next button -


i have <p:wizard> 2 tabs. on first tab, there <p:datatable> , user needs select row keep going. if don't select row, want stop user going next tab , display message. able display message code when click next, next button disappears:

public string onflowprocess(flowevent event) {     //si no eligen un afiliado, desplegar un error: "debe elegir un afiliado para seguir"      if (afiliado.getselectedafi() == null) {         facescontext.getcurrentinstance().addmessage(null,                 new facesmessage("debe de elegir un afiliado para continuar."));          return "afiliadotab";     } else {         return event.getnewstep();     } } 

i put xhtml code, if needed. in above code, afiliadotab name of current tab data table is. telling if afiliado object null (if user doesn't select row), display message , stay there. "stay there" not working well. doing wrong in code?

this xhtml code relevant question (the wizard part):

<p:wizard flowlistener="#{afiliadocontroller.onflowprocess}">     <!-- first tab -->     <p:tab id="afiliadotab" title="afiliado">         <p:panel header="agrega un afiliado" id="panelafiliado">             <!-- <p:messages autoupdate="true" for="validationafiform"/> -->             <p:panelgrid columns="4"  layout="grid">                 <p:outputlabel for="nombres" value="nombres:" />                 <p:inputtext id="nombres" value="#{afiliadocontroller.afiliado.nombre}"                              requiredmessage="debe insertar un nombre."/>                  <p:outputlabel for="apellidos" value="apellidos:" />                  <p:inputtext id="apellidos" value="#{afiliadocontroller.afiliado.apellido}"                              requiredmessage="debe insertar un apellido."/>                  <p:outputlabel for="estadocivil" value="estado civil:" />                  <p:selectonemenu id="estadocivil" effect="drop" value="#{afiliadocontroller.afiliado.estado_civil}"                                  requiredmessage="debe seleccionar un estado civil.">                      <f:selectitem itemlabel="estado civil" itemvalue=""/>                     <f:selectitem itemlabel="soltero" itemvalue="s"/>                     <f:selectitem itemlabel="casado" itemvalue="c"/>                     <f:selectitem itemlabel="union libre" itemvalue="u"/>                     <f:selectitem itemlabel="divorciado" itemvalue="d"/>                     <f:selectitem itemlabel="viudo" itemvalue="v"/>                 </p:selectonemenu>                  <p:outputlabel for="direccion" value="direccion:" />                 <p:inputtext id="direccion" value="#{afiliadocontroller.afiliado.direccion}"/>                 <p:outputlabel for="telefono" value="telefono:" />                  <p:inputmask id="telefono" value="#{afiliadocontroller.afiliado.telefono}" mask="(999) 999-9999"                              requiredmessage="debe insertar un telefono."/>                  <p:outputlabel for="fechanacimiento" value="fecha de nacimiento:"/>                  <p:calendar id="fechanacimiento" yearrange="c-100:c" pattern="yyyy/mm/dd" navigator="true"                             value="#{afiliadocontroller.afiliado.fecha_nacimiento}"                             requiredmessage="debe insertar su fecha de nacimiento."/>                  <p:commandbutton value="insertar" icon="fa fa-save" process="panelafiliado" update="afiliadotable"                                  actionlistener="#{afiliadocontroller.insertafiliado}" />             </p:panelgrid>         </p:panel>          <p:panel header="selecciona un afiliado" id="paneltable">             <!-- tabla con afiliados para seleccionar -->             <p:datatable id="afiliadotable" var="afi" value="#{afiliadocontroller.afiliado.afiliados}" editable="true"                          selection="#{afiliadocontroller.afiliado.selectedafi}"                          rowkey="#{afi.afiliado_id}" editmode="cell" >                  <p:column selectionmode="single" style="width:16px;"/>                  <p:column headertext="afiliado id">                     <h:outputtext value="#{afi.afiliado_id}"/>                 </p:column>                  <p:column headertext="nombres">                     <p:celleditor>                         <f:facet name="output"><h:outputtext value="#{afi.nombre}" /></f:facet>                         <f:facet name="input"><p:inputtext value="#{afi.nombre}" style="width:96%"/></f:facet>                     </p:celleditor>                 </p:column>                  <p:column headertext="apellidos">                     <p:celleditor>                         <f:facet name="output"><h:outputtext value="#{afi.apellido}" /></f:facet>                         <f:facet name="input"><p:inputtext value="#{afi.apellido}" style="width:96%"/></f:facet>                     </p:celleditor>                 </p:column>                  <p:column headertext="eliminar">                     <p:commandbutton icon="fa fa-remove" value="eliminar" process="afiliadotable" update="afiliadotable"                                      actionlistener="#{afiliadocontroller.deleteafiliado(afi.afiliado_id)}" />                 </p:column>                  <f:facet name="footer">                     <p:commandbutton process="afiliadotable" update=":wizard:afiliadodetail" icon="ui-icon-search"                                      value="ver afiliado" oncomplete="pf('afiliadodialog').show()" />                 </f:facet>             </p:datatable>         </p:panel>     </p:tab>      <!-- second tab -->     <p:tab id="beneficiariotab" title="beneficiario">         <p:panel header="agrega beneficiario">             <!-- form para insertar beneficiario -->         </p:panel>         <p:panel header="lista de beneficiarios"></p:panel>     </p:tab> </p:wizard> 

i found wrong. reason, can't use <p:panelgrid> </p:panelgrid>. have use <h:panelgrid></h:panelgrid>.

using <p:panelgrid> </p:panelgrid> causes next button disappear once click on next.

i hope helps someone.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -