2 Replies Latest reply on Jan 18, 2010 4:49 PM by Alexander Bell

    JSF-Events and CDI-Events

    Alexander Bell Newbie

      Hi,


      JSF2.0 introduce a Tag called f:event for triggering SystemEvents.
      IMO it would be great to have a similar tag (maybe the same or with other attributes/attribute-values) to trigger a CDI Event from a JSF Page.


      Example:


      JSF Page



      <h:commandButton action="#{bean.action}" value="Create Document">
         <f:cdiEvent fire="#{bean.document}" select="org.j4fry.cdi.qualifier.Created" />
      </h:commandButton>



      fire contains the observed object which is the parameter of the observer object
      select contains an optinoal qualifier


      CDI Observer Method




      public void createdDocumentObserver(@Observes @Created Document document) {
         ...
      }

      The event is triggerd after the action execution. An additional parameter of f:cdiEvent would be useful that indicates whether the event is triggerd either before or after the action execution.


      <h:commandButton action="#{bean.action}" value="Create Document">
         <f:cdiEvent fire="#{bean.document}" select="org.j4fry.cdi.qualifier.Created" beforeAction="true" />
      </h:commandButton>



      Just an idea.
      What do you think?


      I'm gonna write such a tag because I've got a use case in which it would be useful to use that.


      Alex