5 Replies Latest reply on Apr 18, 2011 6:19 AM by ilya_shaikovsky

    a4j commandbutton render attribute does not work when using immediate="true"

    mano.swerts

      Hi all,

       

      I'm using Richfaces 4 and i'm using a form with the following button:

       

      {code:xml}

           <a:commandButton value="#{msg.reset}" styleClass="cancel" action="#{riskGroupBean.resetNewGroup}" immediate="true" render="createNewGroup"/>

      {code}

       

       

      I am using the immediate="true" attribute to reset the object behind the form without triggering validation. This works but it does not rerender the form. Is this normal? I would expect that the render attributes keeps working when setting immediate="true".

       

      Thanks in advance.

        • 1. Re: a4j commandbutton render attribute does not work when using immediate="true"
          lfryc

          Hi Mano, I have checked and @render works fine with @immediate=true.

           

          What version of RichFaces 4 are you using, could you upgrade to 4.0.0.Final?

           

          Could you provide more details about page and beans?

          • 2. a4j commandbutton render attribute does not work when using immediate="true"
            mano.swerts

            Hi Lukás,

             

            I am using RichFaces 4 Final. I will investigate a little more and get back to you.

             

            Thanks.

            • 3. Re: a4j commandbutton render attribute does not work when using immediate="true"
              mano.swerts

              Hi Lukás,

               

              I investigated this a little bit more. My problem is as follows:

               

              I have a page with a simple backing bean which is annotated with @ViewScoped. I have simple form with a couple of fields which is backed by a POJO through said backing bean. One of the properties of this POJO is annotated with @Max(value=9). I use a rich:message component to show an error message next to the field when a number greater than 9 is entered.

               

              {code:java}
              @Controller
              

              @ViewScoped

              public class PojoBean {

                   private Pojo newPojo = new Pojo();

               

                   // ... getters and setters ...

               

                   public void saveNewPojo() {

                        // persist

                   }

               

                   public void resetNewPojo() {

                        newPojo = new Pojo();

                   }

              }

              {code}

               

               

              {code:java}

              public class Pojo {

                   @Max(value=9)

                   private int property;

               

                   // ...getters and setters...

              }

              {code}

               

              When I enter the number 20 in the text field and hit the tab key, then the error message pops up next to the field. This is ok. After that I hit my cancel button. This button is bound to a reset action. It looks like this in the xhtml code:

               

               

              {code:xml}

              <a:outputPanel id="createNewPojo">

                   <h:form>

                        <h:inputText id="property" label="Property" value="#{pojoBean.property}">

                             <rich:validator />

                        </h:inputText>

               

                        <rich:message for="property" />

               

                        <a:commandButton id="savePojo" value="save" action="#{pojoBean.saveNewPojo}" />

                        <a:commandButton value="reset" action="#{pojoBean.resetNewPojo} immediate="true" render="createNewPojo" />

                   </h:form>

              </outputPanel>

              {code}

               

              The problem is that when I hit the reset It does not rerender my form. It reset the pojo correctly and the error message disappears like it should thanks to the immediate propery, but the number 20 remains in the text field. Even when there is no validation error, the number remains in the text field. When I remove the immediate property, the value for the property is removed from the text field. So my conclusion from this is that the rerender doesn't occur.

               

              Am I trying to tackle this problem in the wrong way?

               

              Thanks in advance.

              • 5. Re: a4j commandbutton render attribute does not work when using immediate="true"
                ilya_shaikovsky

                think that easier solution will be to remove immediate and use ajaxSingle for cancel instead.