validation - Primefaces 2 <h:form> and 2<p:message> confusion -


my login page has 2 forms, 1 login itself, , 1 create new users , in tab view(p:tabview), users never see both on page, be, 1 or another. problem everytime valitation fails on login tab, failure shown in new user tab, , vice-versa. how handle this? tried set update property in buttoncommand, did not work

see code below:

<p:tabview id="logintabview" orientation="right" style="margin-bottom:20px" styleclass="login_fields_panel">         <p:tab title="acesso" id="acessotab" >             <h:form>                 <h3><h:outputtext value="#{bundle.loginhello}"  escape="false"/></h3>                  <p:messages id="messages_login" showdetail="false" autoupdate="true" closable="true" showicon="true"/>                  <p:outputlabel for="email" value="#{bundle.label_email}"/>                 <p:inputtext value="#{loginmb.email}" label="#{bundle.label_email}" id="email" required="true" validatormessage="#{bundle.emailinvalido}" size="45">                     <f:validateregex pattern="^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$" for="email"  />                 </p:inputtext>                  <br/>                  <p:outputlabel for="senha" value="#{bundle.label_password}"  />                 <p:password value="#{loginmb.password}" id="senha" label="#{bundle.label_password}" required="true" size="45"/>                 <br/><br/>                 <p:commandbutton action="#{loginmb.login}" value="#{bundle.btn_login}" ajax="false" update="messages_login"/>             </h:form>         </p:tab>         <p:tab title="faça seu cadastro aqui" id="newuserpanel" >             <h:form id="formnewuser">                 <h3><h:outputtext value="#{bundle.loginhello}"  escape="false"/></h3>                  <p:messages id="messages_new" showdetail="false" autoupdate="true" closable="true" showicon="true" />                 <h:panelgrid columns="2" id="matchgrid" cellpadding="1">                     <p:outputlabel for="email" value="#{bundle.label_name}: "/>                     <p:inputtext value="#{loginmb.email}" label="#{bundle.label_name}:" id="name" required="true" validatormessage="#{bundle.emailinvalido}" size="45" maxlength="100">                     </p:inputtext>                      <p:outputlabel for="email" value="#{bundle.label_email}: "/>                     <p:inputtext value="#{loginmb.email}" label="#{bundle.label_email}" id="email" required="true" validatormessage="#{bundle.emailinvalido}" size="45">                         <f:validateregex pattern="^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$" for="email"  />                     </p:inputtext>                      <p:outputlabel for="senha" value="#{bundle.label_password}"  />                     <p:password value="#{loginmb.password}" id="senha" label="#{bundle.label_password}" required="true" size="45"/>                      <p:outputlabel for="senhaconfirmacao" value="#{bundle.label_password_confirmacao}"  />                     <p:password value="#{loginmb.password}" id="senhaconfirmacao" label="#{bundle.label_password_confirmacao}" required="true" size="45"/>                      <p:outputlabel for="birthday" value="#{bundle.label_birthday}"  />                     <p:calendar id="birthday" value="#{calendarview.date2}" required="true" size="45" pattern="dd/mm/yyyy"/>                 </h:panelgrid>                 <br/><br/>                 <p:commandbutton id="btn_create" action="#{loginmb.createuser}" value="#{bundle.btn_criar_usuario}" ajax="true" update="messages_new"/>             </h:form>         </p:tab> 

thanks

the described problem 2 forms , 2 message components two-fold:

  1. you're using autoupdate="true" on message components. regardless of specify in update attribute, message components will auto-updated.

    you need either remove autoupdate="true" message components, or add ignoreautoupdate="true" command component.


  2. you're using ajax="false" on first button. forces full page reload. note ajax-related attribtes such process , update ignored in such case.

    you need either re-enable ajax on first button, or add redisplay="false" second message component.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -