2 Replies Latest reply on Jan 1, 2008 1:41 PM by Brian Parkinson

    Question about ajax design

    Brian Parkinson Newbie

      Hello -

      Getting into rich faces - kudos all - this is really great. I have a design question - hoping someone can chime in on the "best way".

      I have a tree model object which is serving up an o.r.m.TreeNode object and the tree is displaying loverly. The actual tree data can change by a back end process at any time, so I'd like to be able rerender the tree component when this happens.

      My idea was to use a4j:poll to force an ajax call to the server, and then block in the method until there is a change to the underlying model, at which point the blocked thread continues, and allows the rerender from the client. Something like:

      <rich:tree id="thermostat" .... />

      <a4j:poll id="poll" interval="500"

      but I so far haven't been able to make this work - the processAjax method doesn't get called.

      Then I started to think that this is perhaps not the right way to do this - is it time to delve deeper into the event model in JSF?

      Any help on the preferred design would be great - suspect using a4j:poll is not the best thing here.

      Thanks, and happy holidays.


        • 1. Re: Question about ajax design
          Brian Parkinson Newbie

          Aha - can I use <a4j:push> ?

          Here's part of the xhtml page:

          <rich:tree id="thermostat" style="width:300px" nodeSelectListener="#{thermostatAdaptor.processSelection}"
           reRender="province" ajaxSubmitSelection="true" switchType="client"
           value="#{thermostatAdaptor.treeNode}" var="item">
          <a4j:push reRender="thermostat" eventProducer="#{thermostatAdaptor.addListener}" interval="1000"/>

          and part of the model code:

          public void notifyModified()
           if(listener_ != null)
           listener_.onEvent(new EventObject(this));
          public void addListener(EventListener listener)
           synchronized (listener)
           if(listener_ != listener) listener_ = (PushEventsCounter) listener;

          When I try this, addListener gets called (with a PushEventsCounter). When the tree data is updated (by another process), the notifyModified method is called, but the thermostat is not rerendered.

          Methinks something is missing?

          Any why is there a polling interval on push - is this the time delay between calls to the server?

          Any help is appreciated - the demo doesn't have example code I can steal.



          • 2. Re: Question about ajax design
            Brian Parkinson Newbie

            Doesn't work in FireFox - see:


            I was using FireFox. In the bug report, alexsmirnox reports "this exception does not occur if the FireBug extension is enabled" which I can confirm - when running FireFox with Firebug, the <a4j:push> element works fine.

            Off to check on IE on Windows.