3 Replies Latest reply on Jul 10, 2011 11:40 AM by Deb Briggs

    local graphicImage not re-rendering with a4j:poll

    Deb Briggs Newbie

      Hi - with the following code, the outputText element gets updated every 15 seconds, but the graphicImage (which is being refreshed by another process) is never updated.  I can only see the updated image if I force the browser to reload the page.  I'm using RichFaces 4.0.0.

       

      Here's the xhtml:

       

       

      <html xmlns="http://www.w3.org/1999/xhtml"

            xmlns:ui="http://java.sun.com/jsf/facelets"

            xmlns:h="http://java.sun.com/jsf/html"

            xmlns:f="http://java.sun.com/jsf/core"

            xmlns:a4j="http://richfaces.org/a4j"

            xmlns:rich="http://richfaces.org/rich">

           

            <f:view contentType="text/html">

            <h:head>Test 2</h:head>

            <h:body>

                <h:form>

                   <a4j:poll id="poll" interval="15000" enabled="true" render="poll,grid"  />

                </h:form>

              <h:form>

                         <h:panelGrid id="grid" >

                             <h:outputText id="lastUpdate" value="Last Updated: #{pollBean.date}" />

                             <h:graphicImage id="firstuse" value="/images/FirstUse.gif" />

                         </h:panelGrid>

              </h:form>

           <a4j:log level="ALL" popup="true" width="400" height="200"/>

           </h:body>

        </f:view>

      </html>

       

      and here's the log:

       

       

      info [06:56:10.344]: Received 'begin' event from <span id=j_idt10:poll ...>

      info [06:56:10.362]: Received 'beforedomupdate' event from <span id=j_idt10:poll ...>

      info [06:56:10.367]: Listing content of response changes element:
      Element update for id=j_idt10:poll
      <update id="j_idt10:poll"><![CDATA[<span style="display:none;" id="j_idt10:poll"><script type="text/javascript">new RichFaces.ui.Poll("j_idt10:poll",{"enabled":true,"interval":15000,"ontimer":function(event){RichFaces.ajax("j_idt10:poll",event,{"incId":"1"} )}} )</script></span>]]></update>
      Element update for id=j_idt8:grid
      <update id="j_idt8:grid"><![CDATA[<table id="j_idt8:grid"> <tbody> <tr> <td><span id="j_idt8:lastUpdate">Last Updated: Sun Jul 10 06:56:10 GMT 2011</span></td> </tr> <tr> <td><img id="j_idt8:firstuse" src="/CloudMonitor/images/FirstUse.gif" alt="" /></td> </tr> </tbody> </table> ]]></update>
      Element update for id=javax.faces.ViewState
      <update id="javax.faces.ViewState"><![CDATA[1243136726746240801:-2687977509467206315]]></update>

      info [06:56:10.370]: Received 'success' event from <span id=j_idt10:poll ...>

      info [06:56:10.372]: Received 'complete' event from <span id=j_idt10:poll ...>

       

      There's no server side complaints.  Any leads much appreciated, I've been trying various forms of a4j:outputPanel, a4j:region, addng 'rendered=true' attributes in various places all without success.

        • 1. Re: local graphicImage not re-rendering with a4j:poll
          Deb Briggs Newbie

          (2nd try at posting hte xhtml below):

           

          <html xmlns="http://www.w3.org/1999/xhtml"

                xmlns:ui="http://java.sun.com/jsf/facelets"

                xmlns:h="http://java.sun.com/jsf/html"

                xmlns:f="http://java.sun.com/jsf/core"

                xmlns:a4j="http://richfaces.org/a4j"

                xmlns:rich="http://richfaces.org/rich">

               

                <f:view contentType="text/html">

                <h:head>Test 2</h:head>

                <h:body>

                    <h:form>

                       <a4j:poll id="poll" interval="15000" enabled="true" render="poll,grid"  />

                    </h:form>

                  <h:form>

                             <h:panelGrid id="grid" >

                                 <h:outputText id="lastUpdate" value="Last Updated: #{pollBean.date}" />

                                 <h:graphicImage id="firstuse" value="/images/FirstUse.gif" />

                             </h:panelGrid>

                  </h:form>

               <a4j:log level="ALL" popup="true" width="400" height="200"/>

               </h:body>

            </f:view>

          </html>

          • 2. Re: local graphicImage not re-rendering with a4j:poll
            Deb Briggs Newbie

            and 2nd try at re-posting the log:

             

            info [06:56:10.344]: Received 'begin' event from <span id=j_idt10:poll ...>

            info [06:56:10.362]: Received 'beforedomupdate' event from <span id=j_idt10:poll ...>

            info [06:56:10.367]: Listing content of response changes element:
            Element update for id=j_idt10:poll
            <update id="j_idt10:poll"><![CDATA[<span style="display:none;" id="j_idt10:poll"><script type="text/javascript">new RichFaces.ui.Poll("j_idt10:poll",{"enabled":true,"interval":15000,"ontimer":function(event){RichFaces.ajax("j_idt10:poll",event,{"incId":"1"} )}} )</script></span>]]></update>
            Element update for id=j_idt8:grid
            <update id="j_idt8:grid"><![CDATA[<table id="j_idt8:grid"> <tbody> <tr> <td><span id="j_idt8:lastUpdate">Last Updated: Sun Jul 10 06:56:10 GMT 2011</span></td> </tr> <tr> <td><img id="j_idt8:firstuse" src="/CloudMonitor/images/FirstUse.gif" alt="" /></td> </tr> </tbody> </table> ]]></update>
            Element update for id=javax.faces.ViewState
            <update id="javax.faces.ViewState"><![CDATA[1243136726746240801:-2687977509467206315]]></update>

            info [06:56:10.370]: Received 'success' event from <span id=j_idt10:poll ...>

            info [06:56:10.372]: Received 'complete' event from <span id=j_idt10:poll ...>

            • 3. Re: local graphicImage not re-rendering with a4j:poll
              Deb Briggs Newbie

              FWIW - the issue appears to be that the image was being cached.  I worked around this by adding primeface to my project and using primeface's p:graphicimage.  That allows me to explicitly control the cache setting for each image, i.e. "<p:graphicImage id="firstuse" url="/images/FirstUse.gif" cache="false"/>".

               

              I also read at http://seamframework.org/Documentation/HTTPClientserverOptimizationStrategies:

               

              <snip>

              If you use Richfaces, its resources will be served automatically with a cache expiration timeout of 24 hours (at the time of writing). You could disable this with the <web:ajax4jsf-filter enable-cache="false"/> setting in your components.xml.".

              <snip>

               

              This is good enough for me, though would have liked to be able to use a similar per-resource setting w/ Richfaces.