8 Replies Latest reply on Feb 7, 2012 7:42 AM by ekric

    a4j:support reRender after action delayed

    0vermind

      Hey guys,

      look at the following:

       

      <h:outputText id="text" value="#{bean.mystring}"/>
      <h:commandButton value="update">
               <a4j:support event="onclick" action="#{bean.test}" reRender="text"/>
      </h:commandButton>

       

       

      now test() looks like this:

       

      public void test(){

           mystring="start";

           Thread.sleep(5000);

           mystring="end";

      }

       

      if you click the button, "text" is rerendered, but as "start", meaning the a4j:support doesn't wait until its action is finished to rerender the field. Is there any way to change this behaviour of a4j:support?

        • 1. Re: a4j:support reRender after action delayed
          harut
          use <a4j:commandButton .../> instead of <h:commandButton .../> (no need for a4j:support if needed component already exists in component library...)
          • 2. Re: a4j:support reRender after action delayed
            0vermind

            yes, i know this works, but if i have a standard jsf component without ajax support, i need this a4j:support tag to work.

            is there a way to simulate a click on an a4j:commandButton through a4j:support?

            • 3. Re: a4j:support reRender after action delayed
              ilya_shaikovsky
              again.. just replace h:command with a4j:comand. And that is all.
              • 4. Re: a4j:support reRender after action delayed
                ilya_shaikovsky
                and additional support not needded in this case for sure.
                • 5. Re: a4j:support reRender after action delayed
                  0vermind

                  okay, to clarify this: i DON'T want a button, this was just for the example

                  actually, i have checkbox with a4j:support that produces this behavior, so how to solve this?

                  • 6. Re: a4j:support reRender after action delayed
                    ilya_shaikovsky

                         Please be patient and realize that if you trying to use some pseudocode to illustrate the problem - it should be accurate as the real code is. Because in other case as you see it's highly possible that you will be just pointed to some mistakes in it. And that is not because we do not want to help and investigate the case - but just beacuse we can't imagine the real code used in your app.

                     

                    About the problem i checked with

                    <h:form id="myform">
                         <h:panelGrid columns="2">
                              <h:inputText id="myinput" value="#{userBean.job}">
                                   <a4j:support event="onkeyup" reRender="outtext" action="#{userBean.action}"/>
                              </h:inputText>
                              <h:outputText id="outtext" value="#{userBean.name}" />
                         </h:panelGrid>
                    </h:form>
                    

                     

                    and

                    public void action() throws InterruptedException {
                         this.name="start";
                         Thread.sleep(5000);
                         this.name="finish";
                    }
                    

                     

                    And in the 5 sec I see just "finish" word. Actually there could not be any update till request actually finished. So you should never see the "start" text set in this case.

                    • 7. Re: a4j:support reRender after action delayed
                      pomcompot

                      I got exactly the same problem with this code :

                      <h:form>
                        <rich:extendedDataTable>
                             […]
                             <a4j:support id="takeLivraisonSelection"
                                    event="onselectionchange"
                                    reRender="actionButtons"
                                    action="#{choixLivraison.takeLivraisonSelection}" />
                        </rich:extendedDataTable>

                       

                        <div id="actionButtons">
                            <s:button view="/ChoixEnvironnement.xhtml"
                                    propagation="join"
                                    value="Sélectionner la cible du déploiement"
                                    disabled="#{choixLivraison.selectedLivraison}">
                                <f:param name="from" value="ChoixLivraison" />
                            </s:button>
                        </div>
                      </h:form>

                       

                      getSelectedLivraison is called before choixLivraison.takeLivraisonSelection, so selectedLivraison is empty and my button is never enabled. Don’t understand anything… What can change the order of reRender and action phases?

                       

                      Thanks in advance.

                      • 8. Re: a4j:support reRender after action delayed
                        ekric

                        Since a4j:support doesn't work anymore in Rich Faces 4. Can anybody tell me how to do this with a4j:ajax?

                         

                        EDIT: Got it working with:

                         

                         

                        <h:form id="myform">
                             <h:panelGrid columns="2">
                                  <a4j:queue requestDelay="500" />
                                  <h:inputText id="myinput" value="#{fileSystemBean.name}">
                                       <a4j:ajax event="keyup" render="outtext" />
                                  </h:inputText>
                                  <h:outputText id="outtext" value="#{fileSystemBean.name}" />
                             </h:panelGrid>
                        </h:form>
                        

                         

                        But my problem is, I want my rendering to wait after a commandlink is clicked. This way it doesn't work. Can anybody help?

                         

                         

                        <h:form id="searchresultnodeform">
                             <a4j:queue requestDelay="5000" />
                             <h:commandLink id="searchResultLink"
                                  action="#{fileSystemBean.processSelectionSearch}">
                                  <a4j:ajax event="action" render="wholeContent" />
                                  <h:graphicImage value="/img/searchresult.png" />
                             </h:commandLink>
                        </h:form>