1 Reply Latest reply on May 25, 2009 5:16 AM by ilya_shaikovsky

    A question about a4j:poll

      I have a request-scoped JSF-managed bean like this

      public class Util {
       private final Log log = LogFactory.getLog(getClass());
      
       public long getNumber() {
       return System.currentTimeMillis();
       }
      
       public boolean isSeen() {
       log.debug("hic hic hic ...");
       return true;
       }
      }
      This is the xhtml page
      <h:outputText value="#{util.number}" rendered="#{util.seen}" id="c1" />
      
      <h:panelGroup id="status" style="padding-left: 4px;" layout="block">
       <h:outputText value="#{util.number}" />
      </h:panelGroup>
      
      <a4j:region>
       <h:form>
       <a4j:poll interval="2345" reRender="status2" ajaxSingle="true" limitToList="true"
       bypassUpdates="true" immediate="true"/>
       </h:form>
      </a4j:region>
      Although the number displayed by the component c1 isn't changed, the render condition is checked all the time (i.e. I see the log message for every poll that a4j:poll makes). Why does it happen? and How can I avoid that (in the real project, that render condition queries the database, so it's very costly)?

      Thank you.

        • 1. Re: A question about a4j:poll
          ilya_shaikovsky

          rendered hitting question is not about RichFaces but about JSF in general. You need to be carefull by using EL in rendered because JSF checks the condition at every phase (in order to decide if the component need to be processed on the particular phase, rendered could be changed before any phase by some custom phaseListener).. read this article related to some real applications performance problems. http://jsfcentral.com/articles/speed_up_your_jsf_app_1.html


          the only additional thing related to RichFaces Ajax I want to mention that you should not reRender conditionally rendered element. some parent should be reRendered, because ajax could not insert the content that wasn't already in the DOM.. It could only update existent nodes.