6 Replies Latest reply on Dec 20, 2011 7:12 AM by webmeiker

    Why a4j:commandButton doesn’t reacts at first click?

    webmeiker

      Hi,

      Could somebody explain me why <a4j:commandButton> doesn’t reacts at first click in the next scenario?

      I have to hit it two times in order to get the action executed…

       

       

      facelets composite template named principal.xhtml:

       

       

                <?xml version="1.0" encoding="UTF-8"?>

                <!DOCTYPE html>

       

       

                <html xmlns="http://www.w3.org/1999/xhtml"

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

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

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

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

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

       

       

                          <f:view contentType="text/html">

       

                                    <h:head>

                                              <meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />

                                    </h:head>

       

                                    <h:body>

       

                                              <div id="heading">

                                                        <ui:insert name="heading">

                                                                  <ui:include src="/adm/includes/menu.xhtml"/>

                                                        </ui:insert>

                                              </div>

                                     

                                              <div id="content">

                                                        <br />

                                                                  <a4j:outputPanel ajaxRendered="true">

                                                                            <ui:insert name="content"/>

                                                                  </a4j:outputPanel>

                                                        <br />

                                              </div>   

                                     

                                              <div id="footer">

                                                        <ui:insert name="footer">

                                                                  <ui:include src="/adm/includes/footer.xhtml"/>

                                                        </ui:insert>

                                              </div>

       

                                    </h:body>

       

                          </f:view>

                </html>

       

       

       

       

      The JSF page with the problematic ajax button:

       

       

                          <ui:composition template="/adm/templates/principal.xhtml">

                                    <ui:define name="content">

                                              <rich:panel header="#{msgs.usuariosNuevo}">

       

                                                        <h:form id="formUsuariosNuevo" prependId="false">

       

       

                                                                  <h:panelGrid columns="3">

       

                                                                            <h:outputText value="#{msgs.email}" />

                                                                            <h:inputText value="#{usuarioCtrl.mdl.email}" id="email" />

       

                                                                            <h:outputText value="#{msgs.pwd}" />

                                                                            <h:inputSecret value="#{usuarioCtrl.mdl.pwd}" id="pwd"  />

       

                                                                  </h:panelGrid>

       

       

                                                                  <a4j:commandButton value="#{msgs.guardar}" action="#{usuarioCtrl.guardarUsuarioAction}" />

       

                                                        </h:form>

       

                                              </rich:panel>

                                    </ui:define>

                      </ui:composition>

       

       

       

       

      thanks!

        • 1. Re: Why a4j:commandButton doesn’t reacts at first click?
          mcmurdosound

          have you tried to set ajaxRendered="false"? (in your a4j:outputPanel)

          • 2. Re: Why a4j:commandButton doesn’t reacts at first click?
            healeyb

            I think the problem is that you have an a4j:outputPanel ajaxRendered="true", and this is

            inserting content, which contains a form. I expect that the a4j:outputPanel needs to be

            inside the form, it's worth a try at least!

            • 3. Re: Why a4j:commandButton doesn’t reacts at first click?
              webmeiker

              I’ve just tried your both suggestions with no success…

              (finally I deleted a4j:outputPanel)

               

              I think its a Facelets/templating issue, that causes that the action doesnt get executed until second click.

               

              Same behaviour with h:commandButton

               

              Here is the content of the top toolbar menu menu.xhtml, in case someone want to see it:

               

              <ui:composition>

               

                        <h:form prependId="false" id="formMenu">

               

               

                                  <rich:toolbar height="26px">

               

                                            <rich:dropDownMenu mode="ajax">

                                                      <f:facet name="label">

                                                                <h:panelGroup>

                                                                          <h:graphicImage value="/resources/img/icon/usuarios.png" styleClass="pic" width="20" height="20" />

                                                                          <h:outputText value="Usuarios" />

                                                                </h:panelGroup>

                                                      </f:facet>

                                                      <rich:menuItem label="Nuevo" action="#{menuCtrl.usuariosNuevoAction}" icon="/resources/img/icon/nuevo.png" />

                                                      <rich:menuItem label="Gestión" action="#{menuCtrl.usuariosGestionAction}" icon="/resources/img/icon/gestion.png" />

                                            </rich:dropDownMenu>

               

               

                                            <!-- Others dropDownsMenu's here ... -->

               

                                  </rich:toolbar>

                        </h:form>

               

              </ui:composition>

              • 4. Re: Why a4j:commandButton doesn’t reacts at first click?
                webmeiker

                If I remove mode="ajax" in the rich:dropDownMenu, button is fired correctly, but I loose ajax behaviour in my menu.

                Any clues?

                • 5. Re: Why a4j:commandButton doesn’t reacts at first click?
                  yyq2009

                  If it is not an issue, usually it caused by valuechangelistener. Maybe you can look at html source and which server side action was invoked.

                  • 6. Re: Why a4j:commandButton doesn’t reacts at first click?
                    webmeiker

                    I move this to thread http://community.jboss.org/message/642421#642421

                     

                    ...view source code didnt help in this case because I see markup of the first page loaded, not actual one