5 Replies Latest reply on Sep 8, 2011 4:53 PM by ederfdo

    h:CommandButton action problem

    bkasodariya

      Hi,

      I have created one simple master page. There is cancel button with action in that page.To execute action, I have to press cancel button two times.
      Why its not working on single click.

       

      Here is my jsf page

       

      <!DOCTYPE html 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"

          xmlns:h="http://java.sun.com/jsf/html"

          xmlns:a4j="http://richfaces.org/a4j"

          xmlns:rich="http://richfaces.org/rich"

          xmlns:f="http://java.sun.com/jsf/core"

          xmlns:ui="http://java.sun.com/jsf/facelets">

       

      <h:head></h:head>

      <h:body>

          <h:form id="productMasterForm">

              <rich:panel>

                  <f:facet name="header">

              Product Master

              </f:facet>

                  <h:panelGrid columns="2">

                      <h:outputLabel value="EAN" />

                      <h:inputText value="#{productMaster.ean}"

                          readonly="#{productMaster.editMode}" />

                      <h:outputLabel value="Product Descirption" />

                      <h:inputText value="#{productMaster.productDesc}" />

                  </h:panelGrid>

                  <a4j:commandButton id="save" value="Save"

                      action="#{productMaster.addProduct}">

                  </a4j:commandButton>

                  <h:commandButton  id="cancel" value="Cancel"

                      action="/pages/ProductList.xhtml">

                  </h:commandButton>

                  <h:message showSummary="true" showDetail="false"

                      style="color: red; font-weight: bold;" for="save" />

              </rich:panel>

          </h:form>

      </h:body>

      </html>

        • 1. Re: h:CommandButton action problem
          antoine_h

          hello,

           

          In your page, the form is a h:form.

          is this something you really want ?

           

          you should use a : a4j:form

          this should resolve this kind of double click problem.

           

          also, your first command button is a : a4j:commandButton

          the second one (cancel), is a h:commandButton

           

          I guess you made the h:commandButton to be able to go to the "/pages/ProductList.xhtml" that is outside of the JSF application (in "another" jsf application, in another war, or so...) ?

           

          the more simple use case is to use some a4j:commandButton, for ajax request, in the same JSF application.

           

          for other use case, you might want to look at and use the richfaces htmlCommandLink.

           

          hope it helps.

          Antoine

          JBoss Portal and GateIn (JSR-286), JSF, Richfaces, J2EE, Drools, BRMS.

          http://www.sysemo.com

          • 2. Re: h:CommandButton action problem
            bkasodariya

            Thanks for your response Antonie,

             

            I tried to use a4j:form but its giving tag error at runtime. I am using richfaces 4.0

             

            I am navigation in same jsf application.If i use a4j:commandbutton then i have to click two times.For h:commandbutton its working fine.

             

            Thanks.

            Bharat

            • 3. Re: h:CommandButton action problem
              ashutoshd

              I am also facing the same problem .

              Can any one tell the reason @illya , @bulanos . any one

              • 4. Re: h:CommandButton action problem
                bkasodariya

                Hi,

                 

                Use h:CommandButton and make sure its inside <h:form>

                 

                 

                Thanks,

                Bharat

                • 5. Re: h:CommandButton action problem
                  ederfdo

                  are using the relative path?

                   

                   

                  you must use the path from the root