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

    JSF-Events and CDI-Events

      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

        • 1. Re: JSF-Events and CDI-Events
          nickarls

          I think it would be useful as as event-bridges between servlet/jsf and cdi should be made whereever possible

          • 2. Re: JSF-Events and CDI-Events

            IMO it's simpler to use a declarative syntax (jsf tag in xhtml page) to trigger an event than writing code.


            It would be great to integrate CDI Alternatives and JSF Project Stage. Currentyl I've got on JSF side the project stages development and production (configuration via faces-config.xml). On the other hand I've got my own Weld Alternative Mock (configuration via beans.xml). IMO either a mapping between project-stage and alternatives or an entire integration would be great.