3 Replies Latest reply on May 9, 2011 8:13 AM by ilya_shaikovsky

    a4j:poll getting data twice

    ttsiebzehntt

      Hi,

       

      can perhabs someone help with this issue:

       

      https://issues.jboss.org/browse/RF-10974

       

      With following Frontend

       

      <a4j:poll interval="10000" data="#{testBean.pollData}" oncomplete="alert(event.data);"/>

       

      and bean:

       

      @ManagedBean

      @SessionScoped

      public class TestBean {

       

        int i = 0;

       

        public String getPollData() {

          System.out.println("getPollData()");

          return "" + i++;

        }

      }

       

      we get the following output:

       

      1

      3

      5

      ...

       

      Telling from the stacktraces the getter gets called in ApplyRequestValuesPhase and in RenderResponsePhase. Design or Bug?

       

      We are using Richfaces 4.0 on Tomcat 7.

        • 1. Re: a4j:poll getting data twice
          lfryc

          Hi Martin,

           

          you should rather use action for incrementing the counter, other attributes doesn't ensure that corresponding EL expressions won't be evaluated during request lifecycle.

           

          However when you want to limit the incrementation one-per request, you can for example use following condition:

           

          if (FacesContext.getCurrentInstance().getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
             i++;
          }
          
          • 2. a4j:poll getting data twice
            ttsiebzehntt

            Hi Lukáš,

             

            thanks for the hints.

            So I know how to workaround, but why is it necessary to get the data twice?

            • 3. a4j:poll getting data twice
              ilya_shaikovsky

              actually Martin I think that's a valid issue. data should be used to serialize some server side object in order it to be available for further processing at client side. And I really see no reasons of performing that data population twice. Need to be checked upon 3.3.x and reviewed in order to check the reasons of such behavior.