2 Replies Latest reply on Jun 18, 2010 5:01 PM by shane.bryzak

    Seam Remoting 3 & Observers

    serkan.s.eskici.online.nl

      I'd like to know whether it's possible to have Javascript & AJAX observers with Seam Remoting.


      So let me illustrate this with an example:



      • In the backend, something's changed and an asynchronous event is fired

      • An observer on a @Webremote method gets triggered and handles this change



      So in code:


      @Name("myBean")
      public class MyBean {
      
         public void foo() {
            //do something
            Events.instance().raiseAsynchronousEvent("something.changed");
         }
      }
      
      
      @Name("remotingBean")
      public class RemotingBean {
         
         @Webremote
         @Observer("something.changed")
         public Object getResult() {
             Object result = //get the result
             return result;
         }
      }
      



      JS code:


      jQuery(document).ready(function() {
         Seam.Component.getInstance("remotingBean").getResult(function(result) {
              //show the result in your page
         });
      })
      



      Now the question is whether the JS code gets executed each time the event is fired.


      Is this possible ? -So you update something in the backend and the result is directly shown in the frontend without the need for polling, thus real event driven.