1 Reply Latest reply on Jun 20, 2010 10:22 PM by Nikolay Elenkov

    RaiseEvent and outject

    su baochen Newbie
      Hi all,

      I have two POJOs in the seam application, one raise event and outject the variable and the other observe the event and inject the variable:

      POJO A:
      @Out(required=false)
      private String test;

      @RaiseEvent("hello")
      public void sayHello(){
          this.test  = "123";
      }

      POJO B:

      @In(required=false)
      private String test;

      @Observer("hello")
      public void hello(){
          System.out.println("say hello too:"+test);
      }

      But, when sayHello is called in POJOA, the method hello in POJOB only print out "say hello too:", injected variable test is still null.

      I think the injected variable test should be assigned before the hello method is called, am I right?

      Thanks in advance!

      Su Baochen
        • 1. Re: RaiseEvent and outject
          Nikolay Elenkov Master

          Maybe :) It depends on order of Seam interceptors, and it seems the EventInterceptor gets called before the BijectionInterceptor, that's why you are getting null. Use Events.raiseEvent instead and pass your string as a parameter instead. Something like:


          sayHello() {
            Events.instance().raiseEvent("hello", "123");
          }
          
          @Observer("hello")
          public void hello(String test) {
           ...
          }
          



          HTH