2 Replies Latest reply on Aug 21, 2007 4:40 AM by jonis

    a4j:poll doesn't rerender element

    jonis

      I'm trying to use the a4j:poll tag to update a section of a page. The ajax response contains the updated information(seen by using a4j:log) but the section isn't updated on the page.

      page;

       <a4j:log />
       <a4j:region id="dynamicRegion">
       <div id="dynamicData" class="infoBox">
       <div class="header"><span>#{messages['dynamicData']}</span></div>
       <s:fragment rendered="#{trip.dynamicVesselData ne null}">
       <div class="pack">
       <div class="label">#{messages['informationAge']}:</div>
       <div class="text">#{tripAction.informationAge}</div>
       </div>
       <div class="pack">
       <div class="label">#{messages['longitude']}:</div>
       <div class="text">#{tripAction.longitude}</div>
       </div>
       <div class="pack">
       <div class="label">#{messages['latitude']}:</div>
       <div class="text">#{tripAction.latitude}</div>
       </div>
       <div class="pack">
       <div class="label">#{messages['sog']}:</div>
       <div class="text">#{trip.dynamicVesselData.speedOverGround}</div>
       </div>
       <div class="pack">
       <div class="label">#{messages['cog']}:</div>
       <div class="text">#{trip.dynamicVesselData.courseOverGround}</div>
       </div>
       <div class="pack">
       <div class="label">#{messages['rot']}:</div>
       <div class="text">#{trip.dynamicVesselData.rateOfTurn}</div>
       </div>
       <div class="pack">
       <div class="label">#{messages['navigationalStatus']}:</div>
       <div class="text">#{trip.dynamicVesselData.navigationalStatus}</div>
       </div>
       </s:fragment></div>
       </a4j:region> <h:form>
       <a4j:region>
       <a4j:poll id="poll" action="#{tripAction.updateTrip}"
       interval="10000" reRender="dynamicRegion,:dynamicData"
       enabled="true" />
       </a4j:region>
       </h:form>
      


      response before updated information;
      <?xml version="1.0"?>
      
      <html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><script type="text/javascript" src="
      
      /project/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript">
      
      </script></head><body><div id="dynamicData" class="infoBox"><div class="header"><span>Dynamic trip information
      
      </span></div></div><span style="display:none;" id="j_id23:poll"><script type="text/javascript">//<![CDATA
      
      [
      
      A4J.AJAX.Poll('_viewRoot','j_id23',{'pollId':'j_id23:poll','parameters':{'j_id23:poll':'j_id23:poll'
      
      } ,'pollinterval':10000,'actionUrl':'/project/main.seam'} );
      
      //]]>
      
      </script></span><meta name="Ajax-Update-Ids" content="dynamicRegion,j_id23:poll" /><span id="ajax-update-ids"
      
      ><input type="hidden" name="jsf_sequence" value="1" /><input type="hidden" name="javax.faces.ViewState"
      
       id="javax.faces.ViewState" value="j_id3:j_id5" /></span><meta id="Ajax-Response" name="Ajax-Response"
      
       content="true" /></body></html>



      response after updated information;
      <?xml version="1.0"?>
      
      <html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><script type="text/javascript" src="
      
      /project/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript">
      
      </script></head><body><div id="dynamicData" class="infoBox"><div class="header"><span>Dynamic trip information
      
      </span></div><div class="pack"><div class="label">Age of information:</div><div class="text">51257minutes
      
      </div></div><div class="pack"><div class="label">Longitude:</div><div class="text">4.16</div></div><div
      
       class="pack"><div class="label">Latitude:</div><div class="text">52.0</div></div><div class="pack">
      
      <div class="label">Speed over ground:</div><div class="text">1.0</div></div><div class="pack"><div class
      
      ="label">Course over ground:</div><div class="text">1.0</div></div><div class="pack"><div class="label"
      
      >Turning with a rate of:</div><div class="text">1.0</div></div><div class="pack"><div class="label">Navigational
      
       status:</div><div class="text">UNDERWAY_SAILING</div></div></div><span style="display:none;" id="j_id23
      
      :poll"><script type="text/javascript">//<![CDATA[
      
      A4J.AJAX.Poll('_viewRoot','j_id23',{'pollId':'j_id23:poll','parameters':{'j_id23:poll':'j_id23:poll'
      
      } ,'pollinterval':10000,'actionUrl':'/project/main.seam'} );
      
      //]]>
      
      </script></span><meta name="Ajax-Update-Ids" content="dynamicRegion,j_id23:poll" /><span id="ajax-update-ids"
      
      ><input type="hidden" name="jsf_sequence" value="1" /><input type="hidden" name="javax.faces.ViewState"
      
       id="javax.faces.ViewState" value="j_id3:j_id17" /></span><meta id="Ajax-Response" name="Ajax-Response"
      
       content="true" /></body></html>


      which seams to be correct...

      a4j:log;

      debug[14:17:57,348]: NEW AJAX REQUEST !!! with form :j_id23
      debug[14:17:57,348]: Append hidden control j_id23 with value [j_id23] and value attribute [j_id23]
      debug[14:17:57,348]: Append hidden control javax.faces.ViewState with value [j_id3:j_id20] and value attribute [j_id3:j_id20]
      debug[14:17:57,348]: parameter j_id23:poll with value j_id23:poll
      debug[14:17:57,348]: Start XmlHttpRequest
      debug[14:17:57,348]: Reqest state : 1
      debug[14:17:57,348]: QueryString: AJAXREQUEST=_viewRoot&j_id23=j_id23&javax.faces.ViewState=j_id3%3Aj_id20&j_id23%3Apoll=j_id23%3Apoll&
      debug[14:17:57,363]: Reqest state : 1
      debug[14:17:58,176]: Reqest state : 2
      debug[14:17:58,191]: Reqest state : 3
      debug[14:17:58,191]: Reqest state : 4
      debug[14:17:58,191]: Reqest end with state 4
      debug[14:17:58,191]: Response with content-type: text/xml;charset=UTF-8
      debug[14:17:58,191]: Full response content: .....see code section above....
      debug[14:17:58,191]: Update page by list of rendered areas from response dynamicRegion,j_id23:poll
      debug[14:17:58,191]: search for elements by name 'script' in element #document
      debug[14:17:58,191]: getElementsByTagName found 2
      debug[14:17:58,191]: <script> in response with src=/project/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript
      debug[14:17:58,191]: Such element exist in document
      debug[14:17:58,191]: search for elements by name 'link' in element #document
      debug[14:17:58,207]: getElementsByTagName found 0
      debug[14:17:58,207]: Attempt to update part of page for Id: dynamicRegion
      debug[14:17:58,207]: call getElementById for id= dynamicRegion
      error[14:17:58,207]: New node for ID dynamicRegion is not present in response
      debug[14:17:58,207]: Attempt to update part of page for Id: j_id23:poll
      debug[14:17:58,207]: call getElementById for id= j_id23:poll
      debug[14:17:58,207]: Replace content of node by replaceChild()
      debug[14:17:58,207]: search for elements by name 'script' in element span
      debug[14:17:58,223]: getElementsByTagName found 1
      debug[14:17:58,223]: Scripts in updated part count : 1
      debug[14:17:58,223]: Update part of page for Id: j_id23:poll successful
      debug[14:17:58,223]: call getElementById for id= ajax-update-ids
      debug[14:17:58,223]: Hidden JSF state fields: [object HTMLSpanElement]
      debug[14:17:58,223]: Namespace for hidden view-state input fields is undefined
      debug[14:17:58,223]: search for elements by name 'input' in element span
      debug[14:17:58,223]: getElementsByTagName found 2
      debug[14:17:58,223]: Replace value for inputs: 14 by new values: 2
      debug[14:17:58,223]: Input in response: jsf_sequence
      debug[14:17:58,238]: Input in response: javax.faces.ViewState
      debug[14:17:58,238]: Found same input on page with type: hidden
      debug[14:17:58,238]: Found same input on page with type: hidden
      debug[14:17:58,238]: Found same input on page with type: hidden
      debug[14:17:58,238]: Found same input on page with type: hidden
      debug[14:17:58,238]: Found same input on page with type: hidden
      debug[14:17:58,238]: Found same input on page with type: hidden
      debug[14:17:58,238]: search for elements by name 'INPUT' in element span
      debug[14:17:58,238]: getElementsByTagName found 0
      debug[14:17:58,238]: Replace value for inputs: 14 by new values: 0
      debug[14:17:58,254]: call getElementById for id= _A4J.AJAX.focus
      debug[14:17:58,254]: No focus information in response
      debug[14:17:58,301]: Evaluate script replaced area in document: // A4J.AJAX.Poll('_viewRoot','j_id23',{'pollId':'j_id23:poll','parameters':{'j_id23:poll':'j_id23:poll'} ,'pollinterval':10000,'actionUrl':'/project/main.seam'} ); //
      



      Any ideas of what I'm doing wrong?

      using ajax4jsf-1.1.2-20070813.000131-165.jar

        • 1. Re: a4j:poll doesn't rerender element
          pdpantages

          Hi Jonis, are you able to take the h:form off the second region, or put both regions inside the form? The log complains about not finding dynamicRegion....


          debug[14:17:58,207]: Attempt to update part of page for Id: dynamicRegion
          debug[14:17:58,207]: call getElementById for id= dynamicRegion
          error[14:17:58,207]: New node for ID dynamicRegion is not present in response


          • 2. Re: a4j:poll doesn't rerender element
            jonis

            Hi, thank you for your reply.

            I have solved my problem now. I moved the form tag to include the dynamicRegion as you suggested, this didn't have any effect. The thing that solved it was; I kept your suggested change and in addition to that - replaced the a4j:region tag with a a4j:outputPanel tag. The section now updates as expected.

            -jonis