4 Replies Latest reply on Mar 17, 2008 4:18 AM by mail.micke

    issues with a4j:poll

    jthielscher

      Hi,
      I am quiet new to richfaces and might face some misunderstanding here. I am using RF3.4.1. SR1 under JBPortal 2.6.3. Using a4j:poll I would like to display status changes of background processes in a form. This in general works fine using a button to initiate a bean method with lookup function. However, automation would be required. Therefore I wrote
      code like:

      <a4j:region>
       <h:form>
       <a4j:poll id="poll" immediate="false" interval="1000" reRender="poll,grid" action="#{psb.refresh}"/>
       </h:form>
       </a4j:region>
       <h:form>
       <h:panelGrid columns="1" id="grid">
       <h:panelGroup>
       <h:outputText value="#{psb.requestid}"/> <h:outputText value=" - "></h:outputText> <h:outputText value="#{psb.numberOfStops}" />
       [... some other stuff ...]
       </h:panelGroup>
       </h:panelGrid>
       </h:form>
      


      using the call in action attribute, it executes once as wanted but never again. Using actionExpression instead the phase listener shows continuous repeating of the request but the method is not executed.

      Obviously I would need some help on understand proper calling. Thank you for any hints!

        • 1. Re: issues with a4j:poll
          jthielscher

          Meanwhile I found a work around...
          Implementing the Bean method as listener instead action and calling the same code using the actionListener attribute results in expected behaviour:
          old action method:

          public String refresh() {
           // do something
          return resultValue
          }

          new listener method:
          public void refresh2(ActionEvent ae) {
           //do the same
          }

          and use the a4j:poll with actionListener:
          <a4j:region>
           <h:form>
           <a4j:poll id="poll" reRender="poll, grid" actionListener="#{psb.refresh2}"/>
           </h:form>
          </a4j:region>


          Well, it works now, but I am still a bit confused why it did stop the intervall after 1st iteration using the action attribute. Is this regular behaviour? I would have thought differently... Probably someone who knows better might clarify...
          br


          • 2. Re: issues with a4j:poll
            mail.micke

            Hi,

            Try and returning null from the action method.

            • 3. Re: issues with a4j:poll
              jannie

              Thanks for the suggestion. Did you successfully try it?

              I would expect it to end in a NPE. handleNavigation() should reply with NPE, if outcome is null...

              cheers

              • 4. Re: issues with a4j:poll
                mail.micke

                Hi,
                there is no problem with returning null, it just means redisplay the same page.

                The reason I suggested you try returning null, is because the docs says that that is what should return for an ajax response to take place.
                Have a look at chapter 5.4.4 here:
                http://labs.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html_single/index.html

                Cheers,
                Micke