1 2 Previous Next 15 Replies Latest reply on Jun 17, 2011 6:51 PM by noelmarin

    Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time

    nikh123123

      Hi Guys,

      I'm loading a popupPanel lazily. And have a a4j:commanButton inside the popupPanel which calls a session scoped bean's method. My markup is as follows

       

       

      <h:body>
                <h:form>
                            <a4j:commandLink value="pop me" execute="@this" render="addPanelWrapper">
                                    <f:setPropertyActionListener target="#{userBean.popup}" value="true"/>
                          </a4j:commandLink>
                 </h:form>
       <a4j:outputPanel id="addPanelWrapper" >
                <rich:popupPanel 
                                              id="addPanel"
                                              modal="true"
                                              autosized="true"
                                              rendered="#{userBean.popup}"
                                               show="#{userBean.popup}"           
                                              moveable="true">
              <f:facet name="header">
                  <h:panelGroup>
                      <h:outputText value="Pop me!"></h:outputText>
                  </h:panelGroup>
              </f:facet>
              <f:facet name="controls">
              <h:form>
                        <a4j:commandLink
                        execute="@this" 
                        value="X"
                        oncomplete="#{rich:component('addPanel')}.hide(); return false;">
                                  <f:setPropertyActionListener target="#{userBean.popup}" value="false"/>
                        </a4j:commandLink>
              </h:form>
              </f:facet>
              <h:form>
                        <a4j:log />
                         <a4j:commandButton
                          id="btnSave"
                          execute="@form" 
                          value="Save"
                          action="#{userBean.sayHello}"/>
              </h:form>
          </rich:popupPanel>
      </a4j:outputPanel> 
      
      
      
        </h:body>
      
      

      When I click on the add button for the first time, the sayHello method is not called. If I click on it again, it gets called. I also checked the a4j:log output. Its exactly identical for the a4j button. I ensured that the popup panel is not nested within any form.

       

      Using Richfaces 4.0.0 Final jars + JBoss 5.1.0 GA + Mojarra 2.0.4

       

      What am I missing?

        • 1. Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
          ilya_shaikovsky

          if it will works if you will change

                                                  rendered="#{userBean.popup}"

          to just

                                                  rendered="#{true}"


          for test?

          • 2. Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
            nikh123123

            @Ilya

            Nope. rendered="#{true}"

            gives same behavior.


            • 3. Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
              ilya_shaikovsky

              anything logged in server log?

               

              looks like some weird configuration issue. can't reproduce at rf-showcase environment.

              • 4. Re: Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                nikh123123

                Apart from the following

                 

                14:46:54,333 INFO  [TomcatDeployment] deploy, ctxPath=/regiontest

                14:46:54,390 INFO  [config] Initializing Mojarra 2.0.4 (FCS b09) for context '/regiontest'

                14:47:03,361 INFO  [Cache] Selected fallback cache factory

                14:47:03,362 INFO  [Cache] Creating LRUMap cache instance using parameters: {com.sun.faces.duplicateJARPattern=^tmp\d+(\S*\.jar), org.richfaces.skin=myskin, com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossDelegatingInjectionProvider, org.richfaces.fileUpload.maxRequestSize=1000000, javax.faces.PROJECT_STAGE=Development, maxFilesQuantity=1, uploadRepositoryPath=/tmp, org.richfaces.fileUpload.createTempFiles=false, javax.faces.STATE_SAVING_METHOD=server}

                14:47:03,370 INFO  [Cache] Creating LRUMap cache instance of 512 items capacity

                14:47:03,397 INFO  [Application]  by , version v. SVN r.

                14:47:03,402 INFO  [config] Monitoring jndi:/localhost/regiontest/WEB-INF/faces-config.xml for modifications


                 

                Nothing unusual! Do you want me to paste my web.xml and WEB-INF/lib contents?

                • 5. Re: Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                  mohamida

                  me too i have the same problem.

                  i migrated from richfaces 3.3.3 to 4, and the "action" won't work only after i clicked once.

                  • 6. Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                    nikh123123

                    @moda, You mean with the onclick set you had an issue calling the action, so you removed it and it worked? On the first click?

                     

                    AFAIK, you should have

                     

                     

                    action="#{yourBean.methodName}"

                    oncomplete="#{rich:component('popup')}.hide();"

                     

                    In order to execute both successfully.

                    • 7. Re: Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                      mohamida

                      i modified my message (what i meant with what i said is that i spent much time to figure that the problem is that i have to click 2 times the button so that the "action" will be executed. In fact, before reading your post, i thought that the action isn't executed because of the oncomplete attribute)

                      • 8. Re: Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                        nikh123123

                        ohh ok I got it now.

                        Well I took a workaround for now. My code is as follows

                         

                         

                         

                         

                        <h:body>

                                  <h:form>

                                              <a4j:commandLink value="pop me" execute="@this" render="pgAddWrapper">

                                                      <f:setPropertyActionListener target="#{userBean.popup}" value="true"/>

                                            </a4j:commandLink>

                                   </h:form>



                                  <rich:popupPanel

                                                                id="addPanel"

                                                                modal="true"

                                                                autosized="true"

                                                                rendered="#{userBean.popup}"

                                                                 show="#{userBean.popup}"          

                                                                moveable="true">

                                <f:facet name="header">

                                    <h:panelGroup>

                                        <h:outputText value="Pop me!"></h:outputText>

                                    </h:panelGroup>

                                </f:facet>

                                <f:facet name="controls">

                                <h:form>

                                          <a4j:commandLink

                                          execute="@this"

                                          value="X"

                                          oncomplete="#{rich:component('addPanel')}.hide(); return false;">

                                                    <f:setPropertyActionListener target="#{userBean.popup}" value="false"/>

                                          </a4j:commandLink>

                                </h:form>

                                </f:facet>

                                <h:panelGroup id="pgAddWrapper">

                                            <h:panelGrid rendered="#{userBean.showAddExpensePopup}">

                                                      ... < actual data bound components like inputText, inputArea here> ..

                                            </h:panelGrid>

                                </h:panelGroup>


                                <h:form>

                                          <a4j:log />

                                           <a4j:commandButton

                                            id="btnSave"

                                            execute="@form"

                                            value="Save"

                                            action="#{userBean.sayHello}"/>

                                </h:form>

                            </rich:popupPanel>

                          </h:body>


                         

                        So the key change here is instead of re-rendering the whole popup, i just loaded the contents (i.e. components which interact with user, other than buttons) lazily. In this case the a4j:commandButton works as expected.

                        • 9. Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                          mohamida

                          i have this:

                                  <rich:popupPanel id="popup" width="380" height="200" >

                                      <f:facet name="header">

                                          <h:panelGroup>

                                              Confirmation

                                          </h:panelGroup>

                                      </f:facet>

                                      <f:facet name="controls">

                                          <h:outputLink value="#" onclick="#{rich:component('popup')}.hide(); return false;">

                                              <h:graphicImage value="../IMAGES/close.png" height="16" width="16" styleClass="hidelink" id="hidelink"/>

                                          </h:outputLink>

                                      </f:facet>

                                      <h:panelGroup id="panelGrid">

                                          <table style="width: 100%">

                                              <tr>

                                                  <td style="font-size:16px;" align="right">

                                            Compte n°

                                                  </td>

                                                  <td style="font-weight:bold;font-size:16px;" align="left">

                                                      #{ordreA.cpt.numCpt} - #{ordreA.cpt.libCpt}

                                                  </td>

                                              </tr>

                                              <tr>

                                                  <td align="right" colspan="2">

                                              <h:form id="forme2_saisieVente">

                                                  <h:panelGroup>

                                                      <a4j:commandButton

                                                          action="#{ordreA.acheter}"

                                                          id="ouiBoutton"

                                                          value="Oui"

                                                          render="refOrd,estim,sldTrv,sldAch,valeurCh,acheterBoutton,champMessages,imprimerButton"

                                                          style="width:55px;height:30px;"

                                                          onclick="#{rich:component('popup')}.hide();">

                                                      </a4j:commandButton>

                                                      <span style="width:10px;"></span>

                                                      <a4j:commandButton

                                                          action="#{ordreA.annuler}"

                                                          id="nonBoutton"

                                                          value="Non"

                                                          render="champMessages"

                                                          style="width:55px;height:30px;"

                                                          onclick="#{rich:component('popup')}.hide();">

                                                      </a4j:commandButton>

                                                  </h:panelGroup>

                                              </h:form>

                                              </td>

                                              </tr>

                                          </table>

                                      </h:panelGroup>

                                  </rich:popupPanel>

                           

                          when i removed <h:panelGroup id="panelGrid">, everything worked fine.

                          I don't know why this happened.

                          • 10. Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                            ilya_shaikovsky

                            It's happened because panelGroup by default rendered as span and you have block elements inside. So generated HTML was not valid. you could add layout=block attribute next time to workaround it.

                            • 11. Re: Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                              eduacsp2

                              Im still get the same problem with this:

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                              <rich:column style="width:10px;" width="10"

                              >

                               

                               

                              <a4j:commandLink ajaxSingle="true" styleClass="no-decor" render="editPane" execute="@all"

                               

                              style="text-decoration:center;margin-right: 5px

                              "

                               

                              oncomplete="#{rich:component('editPane')}.show()">

                               

                              <h:graphicImage value="/images/edit.gif" style="border: 0px"/>

                               

                              <a4j:param value="#{it.index}" assignTo="#{order.currentIndex}" />

                               

                              <f:setPropertyActionListener target="#{order.itemEditavel}" value="#{o}" />

                               

                              </a4j:commandLink>

                               

                              </rich:column

                              >

                               

                              .

                              .

                              .

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                              <

                               

                              a4j:outputPanel ajaxRendered="true" layout="block" id="popupPanel"

                              >

                               

                               

                              <rich:popupPanel header="Editar" id="editPane" width="400" height="170" layout="block"

                              >

                               

                              <a4j:commandButton value=

                              "Salvar"

                               

                              action="#{cadastroMasterMBean.salvar}" render=

                              "table"

                               

                              execute=

                              "editPane"

                               

                              oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editPane')}.hide();}"

                              />

                               

                              <a4j:commandButton value=

                              "Cancel"

                               

                              onclick="#{rich:component('editPane')}.hide(); return false;"

                              />

                               

                               

                              </rich:popupPanel

                              >

                               

                              </

                               

                              a4j:output Panel

                              >

                               

                              • 12. Re: Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                                gomul.mind

                                Guys,

                                 

                                I'm facing the same initial issue and I think Eduardo as well,

                                 

                                problem is on popup panel, when button inside the popup panel is click no action is executed, we have to wait until second click to have the action trigered:

                                 

                                In this simple case, when we click on button cloneOrder,  'myModalPanel' is showed. then in the popup panel if I click on Clone button nothing is triggered the first time, second, third .... does.

                                 

                                Any idea?

                                 

                                Many thanks

                                 

                                <a4j:commandButton id="cloneOrder"
                                         value="clone"
                                         render="myModalPanel"
                                         oncomplete="#{rich:component('myModalPanel')}.show()" />

                                ...


                                <rich:popupPanel id="myModalPanel" modal="true" moveable="false"
                                     resizable="false" autosized="true">
                                     <f:facet name="header">
                                      <h:outputText value="Order Clonning" />
                                     </f:facet>
                                     <f:facet name="controls">
                                      <h:outputLink value="#"
                                       onclick="#{rich:component('myModalPanel')}.hide(); return false;">X</h:outputLink>
                                     </f:facet>
                                     <h:form id="myModalPanelForm">
                                      <h:panelGrid columns="2">      
                                       <a4j:commandButton value="Clone"
                                        execute="@this"
                                        action="#{layoutDataBean.cloneOrder}"/>
                                       <a4j:commandButton id="cancelCloneButton" value="Cancel"
                                        onclick="#{rich:component('myModalPanel')}.hide();return false;"/>
                                      </h:panelGrid>
                                     </h:form>
                                </rich:popupPanel>

                                 

                                • 13. Re: Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                                  noelmarin

                                  Alf, I had the same issue and the solution for me was the answer number 8 of this post, about not putting in the a4j:commandButton render attribute the popupPanel id, otherwise put the id of the other container.

                                   

                                  For your case create other container inside the popupPanel form, for instance an a4j:outputPanel or a h:panelGrid with an id, then put that id in the render attribute of the a4j:commandButton id="cloneOrder", and take special attention to the container of the commandButton that execute the action outside of the container mentioned before.

                                   

                                  I hope you understant

                                  • 14. Re: Richfaces 4 - a4j:commandButton inside a lazily loaded rich:popupPanel doesn't execute first time
                                    julio49

                                    I am having the same problem as Alf post #12.  I call a popup panel, I enter data and click a <a4j:commandButton> and it calls the action function from the  managed bean fine.  If I close the popup panel and reopen the popup  and try to click the <a4j:commandButton>, the action function is not call the the first time but it will the second time I click the <a4j:commandButton>

                                     

                                    Here is an example code:

                                     

                                    <!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:ui="http://java.sun.com/jsf/facelets"

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

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

                                     

                                    <body>

                                              <ui:composition 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">

                                     

                                     

                                                        <rich:panel header="Comments" headerClass="text"

                                                                  style="height:320px; width:100%;">

                                                                  <h:inputTextarea value="#{commentsBean.listCommentsForOperation}"

                                                                            style="height:240px;width:100%;font-size:12pt;" readonly="true"

                                                                            id="operationCommentsTable" />

                                     

                                                                  <h:commandButton value="Add Comments" style="font-size:12pt;"

                                                                            onclick="#{rich:component('operationCommentsPopup')}.show()" >

                                                                  </h:commandButton>

                                     

                                                                    <rich:popupPanel id="operationCommentsPopup" modal="true"

                                                                            autosized="true" resizeable="false" style="text-align:center;">

                                                                            <f:facet name="header">

                                                                                      <h:outputText value="Comment Upload" styleClass="text" />

                                                                            </f:facet>

                                                                            <f:facet name="controls">

                                                                                      <a4j:commandLink value="X"

                                                                                                oncomplete="#{rich:component('operationCommentsPopup')}.hide(); return false;"

                                                                                                style="font-size:14pt;color:#FFFFFF;"

                                                                                                render="operationCommentsPopupForm" />

                                                                            </f:facet>

                                       

                                                                            <h:form id="operationCommentsPopupForm">

                                                                                      <h:panelGrid id="commentinputpanel" columns="2" border="0">

                                                                                                <h:outputText value="Comments:" styleClass="text" />

                                                                                                <h:inputTextarea value="#{commentsBean.comment}" cols="75"

                                                                                                          rows="8" required="true" id="inputComment">

                                                                                                          <rich:validator />

                                                                                                </h:inputTextarea>

                                                                                                <h:outputText value="" />

                                                                                                <rich:message for="inputComment" />

                                                                                      </h:panelGrid>

                                     

                                     

                                                                                      <a4j:commandButton value="Save Comment" id="savecommentbtn"

                                                                                                action="#{commentsBean.saveOperationCommentsFunction}"

                                                                                                render="operationCommentsTable,errorPopup" style="font-size:14pt;">

                                                                                      </a4j:commandButton>

                                     

                                                                                      <div style="width:100%;text-align:center;"><h:outputText id="commentSubmitStatus"

                                                                                                value="#{commentsBean.submitStatus}" style="font-size:10pt" /></div>

                                     

                                                                            </h:form>

                                                                  </rich:popupPanel>

                                                        </rich:panel>

                                     

                                               </ui:composition>

                                    </body>

                                    </html>

                                     

                                     

                                    Any suggestion on how to resolve this issue?

                                    1 2 Previous Next