1 Reply Latest reply on Jan 6, 2011 3:55 AM by ilya40umov

    a4j:commandButton submit whole page

    peterbasutkar

      Hi All

      Requirement : how to avoid page submission on <a4:commandButton> click event.

       

      Description : i am using rich faces 3.3.1 and gravel tag library.

                         we have a requirement to call action befor page renders ,because of this we used gravels <ga:responseActions> tag but all the actions inside <ga:responseActions> should get called only when page renders first time , but whenever i call my action using <a4j:commandButton> then bean method is getting called first and then all the actions inside <ga:responseActions> gets calles again.

                           on any action using <a4j:commandButton> in that page all the actions inside <ga:responseActions> are getting called and i want to restrict that from happening

       

      my page is as follows

                   <ga:responseActions>
                      <f:setPropertyActionListener target="#{name}" value="#{myBean.name}"/>
                  </ga:responseActions>

       

                  <h:form>
                     <a4j:outputPanel id="panel" ajaxRendered="true">
                       <h:inputText value="#{myBean.address}" />
                       <a4j:commandButton value="submit" action="#{myBean.next}" reRender="panel"/>
                       <h:outputText value="#{myBean.zipCode}" />
                    </a4j:outputPanel>
                </h:form>

       

       

             is there any equivalent solution in jsf(richFaces,a4j) compared to gravel.

        • 1. Re: a4j:commandButton submit whole page
          ilya40umov

          Do you use f:setPropertyActionListener + ga:responseActions in order to set some bean parameters when bean just has been created?

          If so you can easily use the following approach in your faces-config.xml:

          <managed-bean>
                  <managed-bean-name>someBean</managed-bean-name>
                  <managed-bean-class>
                      com.test.SomeBean
                  </managed-bean-class>
                  <managed-bean-scope>request</managed-bean-scope>
                  <managed-property>
                      <property-name>name</property-name>
                      <value>#{name}</value>
          </managed-property>
          </managed-bean>

          <managed-bean>

                  <managed-bean-name>someBean</managed-bean-name>

                  <managed-bean-class>

                      com.test.SomeBean

                  </managed-bean-class>

                  <managed-bean-scope>request</managed-bean-scope>

                  <managed-property>

                      <property-name>name</property-name>

                      <value>#{name}</value>

               </managed-property>

          </managed-bean>