1 Reply Latest reply on May 31, 2010 3:03 AM by Rob Acraman

    how do i rerender faces messages or required messages only once?

    sathish avunoori Newbie

      hi to all,

       

      my simple scenario  like this ,

       

      i have a user registration screen in my seam application,

      some code as follows in xhtml file,

      <h:form id="myform">

      <rich:panel >
                 <f:facet name="header">#{messages['com.infyz.toms.entity.User']}</f:facet>
                  <table style="width:100%;text-align:right;">
                      <tr>
                          <td>
                              <s:decorate id="userNameField" template="../layout/edit.xhtml">
                                <ui:define name="label">#{messages.Username}</ui:define>
                                  <h:inputText id="userName" required="true" requiredMessage="Username required" size="15"
                                      maxlength="25" value="#{user.userName}">
                                      <f:validator validatorId="userNameValidator" />
                                      <f:attribute name="userId" value="#{user.userId}" />
                                      <a:support event="onblur" reRender="userNameField"
                                          bypassUpdates="true" ajaxSingle="true" />
                                  </h:inputText>
                              </s:decorate>
                          </td>

                          <td>
                              <s:decorate id="passwordField" template="../layout/edit.xhtml">
                                  <ui:define name="label">#{messages['com.infyz.toms.properties.Password']}</ui:define>
                                  <h:inputSecret id="password"
                                                 required="true"
                                                 requiredMessage="Password Required"

                                                 size="15"
                                                 maxlength="100"
                                                 redisplay="true"
                                                 value="#{user.password}">
                                     <a:support event="onblur" reRender="passwordField" bypassUpdates="true" ajaxSingle="true"/>
                                  </h:inputSecret>
                              </s:decorate>
                              </td>

                              <td >
                              <s:decorate id="emailIdField" template="../layout/edit.xhtml"  >
                                  <ui:define name="label">#{messages['com.infyz.toms.properties.Email_id']}</ui:define>
                                  <h:inputText id="emailId"
                                              required="true"
                                               requiredMessage="e-mail required"

                                               size="15"
                                               maxlength="100"
                                               value="#{user.emailId}">
                                      <a:support event="onblur" reRender="emailIdField" bypassUpdates="true" ajaxSingle="true"/>
                                  </h:inputText>
                              </s:decorate>
                          </td>

                          </tr>

      <tr>
                          <td >
                              <s:decorate id="firstNameField" template="../layout/edit.xhtml">
                                  <ui:define name="label">#{messages['com.infyz.toms.properties.First_name']}</ui:define>
                                  <h:inputText id="firstName"
                                              required="true"
                                               requiredMessage="first name required"

                                               size="15"
                                               maxlength="100"
                                               value="#{user.firstName}">
                                      <a:support event="onblur" reRender="firstNameField" bypassUpdates="true" ajaxSingle="true"/>
                                  </h:inputText>
                              </s:decorate>
                          </td>
                          <td >
                              <s:decorate id="middleNameField" template="../layout/edit.xhtml" >
                                  <ui:define name="label">#{messages['com.infyz.toms.properties.Middle_name']}</ui:define>
                                  <h:inputText id="middleName"                      
                                               size="15"
                                               maxlength="100"
                                               value="#{user.middleName}">
                                      <a:support event="onblur" reRender="middleNameField" bypassUpdates="true" ajaxSingle="true"/>
                                  </h:inputText>
                              </s:decorate>
                          </td>
                          <td >
                              <s:decorate id="lastNameField" template="../layout/edit.xhtml" >
                                  <ui:define name="label">#{messages['com.infyz.toms.properties.Last_name']}</ui:define>
                                  <h:inputText id="lastName"
                                               size="15"
                                               maxlength="100"
                                               value="#{user.lastName}">
                                      <a:support event="onblur" reRender="lastNameField" bypassUpdates="true" ajaxSingle="true"/>
                                  </h:inputText>
                              </s:decorate>
                          </td>
                      </tr>

      </table>

      </rich:panel>

      <a4j:commandLink id="save1" action="#{userAction.persist}"
                                 rendered="#{ userAction.valid}"
                                 oncomplete="if (#{facesContext.maximumSeverity!=null}) #{rich:component('editCargoPosition1')}.show();" >
                                 <h:graphicImage value="#{messages['com.infyz.toms.label.button.Save']}" style="border:0"    length="17"  width="15"/>
                 </a4j:commandLink>

       

       

       

      <rich:modalPanel id="editCargoPosition1" >
                  <f:facet name="header"><h:outputText value="#{messages['com.infyz.toms.label.Data_Validation_Results']}" /></f:facet>
                    <f:facet name="controls">
                        <h:graphicImage value="#{messages['com.infyz.toms.label.button.Cancel']}"
                            styleClass="linkImage"
                               onclick="#{rich:component('editCargoPosition1')}.hide()" />
                   </f:facet>
                 <rich:messages style="#{messages['com.infyz.toms.messages.Color']}:red;"/>
                  <div align="center">
                        <input type="button" value="#{messages['com.infyz.toms.label.button.tooltip.Ok']}" onclick="#{rich:component('editCargoPosition1')}.hide()"/>
                  </div>
        </rich:modalPanel>

      </h:form>

       

      in this page i have some fields with some required fields like username and password etc.........for user registration .

      when i click on a4j:commandLink  the required messages are diplaying on modelpanel("editCargoPosition1")  if not filled by user.

       

      as well as those messages are rendering on my xhtml page also.

       

       

      my requirement is , i need to display those required messages either on modelpanel("editCargoPosition1") or on my xhtml page .

       

      can any one tell me how would i do this?

       

       

      thanks in advance.