3 Replies Latest reply on Apr 25, 2008 9:07 AM by trumml

    Form validation does not dissappear

    trumml

      I have the following page (simplified):


      <a4j:form id="personForm">
        <h:selectOneMenu value="person">
          <s:selectItem value=#{allPersons} var="person" label="person.name"/>
          <a4j:support event="onchange" action="#{mb.updatePerson}" reRender="personForm" ajaxSingle="true"/>
        </h:selectOneMenu>
      
        <s:decorate template="editDecoration.xhtml">
          <h:inputText value="person.name" required="true"/>
        </s:decorate>
      
        <h:inputText id="age" value="person.age" required="true" />
        <h:message for="age" />
      
        <a4j:commandButton action="mb.savePerson" />
      </a4j:form>



      When I open this page and press the save button, the validation fails because no age and name is given and an error message occurs.
      Now when I use the drop down box to select another person (without submitting the form correctly again) the form gets re rendered but the validation message for the name input field does not dissappear. For the age input field it works.


      How can I hide all validation messages? Within editDecoration.xhtml I use the #{invalid} flag.

        • 1. Re: Form validation does not dissappear
          andygibson.contact.andygibson.net

          Off the top of my head, try adding 'immediate="true"' to the supports tag.


           <a4j:support event="onchange" action="#{mb.updatePerson}" reRender="personForm" ajaxSingle="true" *immediate="true"*/>
          



          This would cause the validation code to be bypassed and no error messages returned.


          Cheers,


          Andy Gibson

          • 2. Re: Form validation does not dissappear
            andygibson.contact.andygibson.net

            D'oh, the "*" around the immediate="true" in the code sample are not needed, I was trying to emphasize the added text.


            It should be :


            <a4j:support event="onchange" action="#{mb.updatePerson}" 
                reRender="personForm" ajaxSingle="true" immediate="true"/>
            



            Cheers,


            Andy

            • 3. Re: Form validation does not dissappear
              trumml

              This does not work for me.



              <h:selectOneMenu value="mb.person">
                <s:selectItem value=#{allPersons} var="person" label="person.name"/>
                <a4j:support event="onchange" action="#{mb.updatePerson}" reRender="personForm" ajaxSingle="true" immediate=true"/>
              </h:selectOneMenu>



              When I add the immediate attribute the mb.setPerson(person) method is no more called when selecting another person in the drop down.