5 Replies Latest reply on Dec 20, 2007 11:58 AM by pmuir

    seam events

    skanky78

      hi,

      i'm having problems with seam events definied in components.xml. if a certain events occurs a method with a string as an argument shall be called.

      example:

      <components>
       <event type="say">
       <action execute="#{exampleListener.saySomething}"/>
       </event>
      </components>
      



      @Name("example")
      public class Example {
       public void saySomething() {
       FacesMessages.instance().add("Hello World");
       Events.instance().raiseEvent("say", "Hello World");
       }
      }
      



      @Name("exampleListener")
      public class ExampleListener {
       public void saySomething(String text) {
       FacesMessages.instance().add(text);
       }
      }
      


      this example does'nt work because seam tries to find a method named 'saySomething' without any argument. but how can i define that a method with an argument (e.g. string) shall be executed? is this possible via components.xml?

      cheers,
      sven

        • 1. Re: seam events
          pmuir

          No, you should use the Seam contexts to pass variables.

          • 2. Re: seam events
            skanky78

            quote from the seam manual:

            ...Notice that this event producer has no dependency upon event consumers. The event listener may now be implemented with absolutely no dependency upon the producer..


            so you mean i have to introduce a dependency upon the producer, right?

            can you give a short solution for my simplified example? how can i get the event state (argument "Hello World") of the fired event in event listener? at the moment i'm not seeing the wood for the trees...

            thanks,
            sven

            • 3. Re: seam events
              pmuir

              Ok, so the simple answer is no, its not possible from components.xml

              • 4. Re: seam events
                skanky78

                thank you for your reply pete, but my second question targeted on how to do it the way you mentioned:

                No, you should use the Seam contexts to pass variables.


                you mean i should use @OUT for the producer and @IN for the consumer. is that the right way?

                cheers,
                sven



                • 5. Re: seam events
                  pmuir

                  Exactly.