5 Replies Latest reply on Jul 4, 2012 1:14 PM by cacelis

    No rerender after validation failed


      I have the following problem.

      I have two required field x1 and x2 and a save button. On every change x.swap is called via a4j:support. If both field have not null value then swap swaps the value of the two field.

      Everything works fine except there is a validation error. After that the fields are not rerendered.

      Scenario: I write 1 into the first field (x1) then I click on save. Value is required message comes. Now I write 2 into the second field (x2). The x.swap is called and the second field is rerendered but the first field does not. It still shows 1 but the field x.x1 have the value 2. I debugged and x.getX1() is not even called after I clicked save.

      In our project this happens everywhere where a field is calculated based on other fields. After a validation error these fields stop rerendering.

      We use Seam 2.0.2.SP1 + JBoss 4.2.3.GA + RichFaces 3.2.2.SR1. But I tried different Seam and RichFaces versions and got the same result.

      I ran out of any idea. So any help is appreciated.

      Here is the x.xhtml

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
                <h:inputText id="X1" value="#{x.x1}" required="true">
                     <a4j:support eventsQueue="queue" event="onchange" ajaxSingle="true"
                          action="#{x.swap}" reRender="X1,X2" />
                <h:inputText id="X2" value="#{x.x2}" required="true">
                     <a4j:support eventsQueue="queue" event="onchange" ajaxSingle="true"
                          action="#{x.swap}" reRender="X1,X2" />
                <a4j:commandButton value="save"
                     eventsQueue="queue" action="#{x.save}" reRender="X1,X2" />

      And x.java

      public class X implements XLocal 
           private Integer x1;
           private Integer x2;
           public void create()
           public Integer getX1()
                return x1;
           public void setX1( Integer pX1 )
                x1 = pX1;
           public Integer getX2()
                return x2;
           public void setX2( Integer pX2 )
                x2 = pX2;
           public void swap()
                if(x1==null || x2==null)
                Integer x = x1;
           public void save()
           public void destroy()

        • 1. Re: No rerender after validation failed

          Have you solved this??

          I have the same issue, these are the steps:
          1. Try to save a form.
          2. Required validation fails on the validation phase (on purpose).
          3. Click on a button that changes the object to the default on the server side.
          4. The controls are not rendered with the values setted.
          5. F5 on the browser and the values are correctly rendered.

          Thanks in advance.

          • 2. Re: No rerender after validation failed

            After some days I could finally solved this.

            I found these:

            And after reading them through I write this little utility method:

                 private static void clearComponent(UIComponent pComponent)
                      if ( pComponent instanceof EditableValueHolder )
                           EditableValueHolder editableValueHolder = (EditableValueHolder) pComponent;
                           editableValueHolder.setSubmittedValue( null );
                           editableValueHolder.setValue( null );
                           editableValueHolder.setValid( true );
                      for(UIComponent child : pComponent.getChildren())
                           clearComponent( child );

            And I call it with the form as the parameter (I find it by id through FacesContext.getCurrentInstance().getViewRoot().) It should be called from the a4j:support called method. In my example the call should be in swap().

            I hope this helps for you too.

            • 3. Re: No rerender after validation failed

              I was the same problem and your post helped me!!

              Thank you very much!!

              • 4. Re: No rerender after validation failed

                It works form me.

                Thanks! :)

                • 5. Re: No rerender after validation failed

                  It worked for me too!


                  Thank you very much!