3 Replies Latest reply on Nov 2, 2010 9:40 AM by ziyang

    Control the execution order in Richfaces

    ziyang

      Hi All,

      I build a table with several rows. And put a commandlink in each row.

      What I want is:

      Step1:

      if the link is clicked, an action binded to a method in the bean is fired, meanwhile the id of the row is passed as param, so some data could be retrieved from DB according to the id and then stored in the bean.

      Step2:

      Then model panel can display the data I just retrieved from DB.

       

      But the fact is that. Step1 does not execute before step 2. So if I clicked the link, data retrieved when the last time the link is clicked is displayed. So, data of the current row is not displayed, the data of last clicked row is displayed.

       

      Could some body tell me if there any mechanism to control this?

      Or could I realize my goal in other ways? Now I can only click the link, fire the action, get the data, and show the data in a new page, which is not good, I want to stay in the same page.

      And for some reason, I can not get the data in advance when the table is built, I have to query DB to get it dynamically.

       

      Thank you very much!!

        • 1. Re: Control the execution order in Richfaces
          ziyang

          Got an answer!!!

          This blog helped me. Although the solution in the blog did not work for me, I get a workable solution from the comments.

          http://www.digitalsanctuary.com/tech-blog/java/jboss/seam/displaying-and-rerendering-a-richfaces-modalpanel-from-a-commandlink.html/comment-page-1#comment-74749

           

          Here is a my piece of workable code. Ask me if you have any questions!!!

          <rich:column>
                      <a4j:commandLink id="link" action="#{SortableTable.sayHi}" oncomplete="#{rich:component('panel')}.show()" >
                          <f:param name="name" value="#{row.name}" />
                          Show Modal Panel
                      </a4j:commandLink>
                     
                      <rich:modalPanel id="panel" width="350" height="100">
                          <f:facet name="header">
                              <h:outputText value="Modal Panel"></h:outputText>
                          </f:facet>
                 
                          <f:facet name="controls">
                              <h:panelGroup>
                                 <h:commandLink value="aaa" id="hidelink"/>
                                  <rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
                              </h:panelGroup>
                          </f:facet>

                      
                          <a4j:outputPanel ajaxRendered="true">
                              <h:outputText value="#{SortableTable.content}"></h:outputText>
                          </a4j:outputPanel>
                     </rich:modalPanel>
                  </rich:column>

          • 2. Re: Control the execution order in Richfaces
            liuliu

            hi,

            you need a renrender in your commandlink. i think ajaxRendered attribute is not fit.

             

            hope this help.

             

            liu

            • 3. Re: Control the execution order in Richfaces
              ziyang

              Thank you for your advise.The code I posted after my question is a piece of totally workable code. Thanks a lot.