1 Reply Latest reply on Feb 6, 2009 12:38 AM by Carey Foushee

    Asynchronous Event and Observer

    michelle park Newbie

      I created a publisher and an observer of an event.  I would like to know if there's a way to return values from an observer to a publisher and even display FacesMessages from Observer in jsf page.  Please see my sample code below:


      @Stateful
      @Scope(ScopeType.SESSION)
      @Name(myClass)
      public class MyClass{


          public void myMethod() {
              Events events = Events.instance();
              events.raiseAsynchronousEvent(observerName);
          }
      }



      @Name(myObserver)
      public class ObserverClass {
         
          @Observer(observerName)
          public String observerMethod() {
              FacesMessages.instance().add(I want to show this message on the screen for users);
              return can I return this String to the event producer - myClass.myMethod();
          }


      }



      The code itself will tell you what I want to do.  Once the event is completed, I want to display some message (as shown in the FacesMesssages in the observerMethod.)  But this doesn't work.  Also, how can I handle an exception?  For now, I think I can use FacesMessages for user-friendly message (if this is possible.)  is there any better way for exception handling in this case?


      Please help.


      Thank you.
      Michelle