1 Reply Latest reply on May 1, 2007 10:25 AM by Sergey Smirnov

    Problem with a4j:poll and rendering t:graphicImage

    David Paterson Newbie

      I have a simple example where I am trying to create progress bar that will render a chart image once it has been created. I have reduced my scenario to very simplified version of the effect I am trying to achieve and having some problems.

      My JSP:

      <a4j:region id="progress_bar_region">
      <a4j:poll id="poller" ignoreDupResponses="false"
       enabled="#{progressBarUtil.percentage < 200}"
       action="#{progressBarUtil.incCounter}"
       reRender="poller,test_image,percentage_done,progress_bar_div,progress_bar_region,text"
       interval="10"
       ajaxSingle="false"
       bypassUpdates="false"
       immediate="false"
       limitToList="true"/>
       <t:panelGrid align="center" columns="1" width="210"
       rowClasses="class_progress_bar_percentage, class_progress_bar_center"
       rendered="#{progressBarUtil.percentage < 200}" forceId="true" id="progress_bar_table" >
       <t:outputText rendered="#{progressBarUtil.percentage < 200}"
       style="TEXT-ALIGN: center" forceId="true" id="percentage_done"
       value="#{progressBarUtil.percentage}% Complete"/>
       <t:div style="TEXT-ALIGN: center" forceId="true"
       id="progress_bar_div"
       styleClass="class_progress_bar"
       style="width:#{progressBarUtil.pbWidth}px;"
       rendered="#{progressBarUtil.percentage < 200}">
       </t:div>
       </t:panelGrid>
      
      <t:graphicImage url="images/tokeep/logo_ellacoya.gif"
       forceId="true" id="test_image" rendered="#{(progressBarUtil.complete=='COMPLETE')}"/>
      
       <%-- so I'm seeing COMPLETE below but still no image rendering above. --%>
       <t:outputText forceId="true" id="text" value="#{progressBarUtil.complete}"></t:outputText>
      </a4j:region>


      My bean:
      public class ProgressBarUtil implements Serializable {
      
       private static final long serialVersionUID = -4472975089898552309L;
      
       private static final EllacoyaLogger logger = EllacoyaLogger.getLogger(ProgressBarUtil.class);
      
       //status bar stuff
       private Integer percentage = 1;
      
       private Integer pbWidth;
      
       private Integer pbHeight;
      
       private String complete = "NOT_COMPLETE";
      
       public int getPercentage() {
       logger.info("getPercentageCalled percentage : " + percentage);
       setPbWidth(percentage);
       return percentage;
       }
      
       public void setPercentage(int percentage) {
       logger.info("setPercentageCalled");
       this.percentage = percentage;
       }
      
       public int getPbHeight() {
       return 25;
       }
      
       public void setPbHeight(int pbHeight) {
       this.pbHeight = pbHeight;
       }
      
       public int getPbWidth() {
       logger.info("getPbWidth, width is : " + pbWidth);
       return percentage*2;
       }
      
       public void setPbWidth(int pbWidth) {
       this.pbWidth = pbWidth;
       }
      
       public String incCounter() {
       logger.info("incCounter called " + percentage);
       percentage= (2*percentage++);
       if (percentage > 100) complete="COMPLETE";
       return null;
       }
      
       public String getComplete() {
       logger.info("getComplete called, complete is: " + complete);
       return complete;
       }
      
       public void setComplete(String complete) {
       this.complete = complete;
       }
      }


      My log:
      09:18:37,343 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 64
      09:18:37,343 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 64
      09:18:37,343 [INFO ] [ProgressBarUtil] getComplete called, complete is: NOT_COMPLETE
      09:18:37,343 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 64
      09:18:37,343 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 64
      09:18:37,343 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 64
      09:18:37,343 [INFO ] [ProgressBarUtil] getComplete called, complete is: NOT_COMPLETE
      09:18:37,343 [INFO ] [ProgressBarUtil] incCounter called 64
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPbWidth, width is : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getPercentageCalled !!!!! percentage : 128
      09:18:37,359 [INFO ] [ProgressBarUtil] getComplete called, complete is: COMPLETE
      09:18:37,359 [INFO ] [ProgressBarUtil] getComplete called, complete is: COMPLETE
      09:18:37,359 [INFO ] [ProgressBarUtil] getComplete called, complete is: COMPLETE
      09:18:37,359 [INFO ] [ProgressBarUtil] getComplete called, complete is: COMPLETE
      09:18:37,390 [INFO ] [SessionFilter] done: logged in



      So my "rendered" expression for the graphic image should be returning true when the counter passes 100 and the image should show up but this is not the case. The image component is never rendered. Incidentally if I change the expression to complete !="COMPLETE" it's always rendered.

      Also the progress bar works great but is not supposed to render once percentage passes 200 but yet it remains on the page.

      Anyone have any ideas?

        • 1. Re: Problem with a4j:poll and rendering t:graphicImage
          Sergey Smirnov Master

          First rule - do not point to the component that has 'rendered' attribute, point to the one of the parent component without this attribute.
          As an alternative, you can surround the component with <a4j:outputPanel layout="none">

          I.e, for example:
          <a4j:outputPanel layout="none">
          <t:graphicImage url="images/tokeep/logo_ellacoya.gif"
          forceId="true" id="test_image"
          rendered="#{(progressBarUtil.complete=='COMPLETE')}"/>
          </a4j:outputPanel>