2 Replies Latest reply on Nov 16, 2006 3:04 AM by Isabella Kneissl

    PhaseListener as Seam Component

    Isabella Kneissl Newbie

      Hi,

      is it possible, to annotate a phase listener as seam bean and to inject another bean?

      my code looks like this:

      ##############
      the phase listener:

      @Name("keeper")
      @Scope(ScopeType.SESSION)
      @Intercept(InterceptionType.ALWAYS)
      public class KeeperPhaseListener implements PhaseListener {

      public KeeperPhaseListener() { }

      @In(value="navBean", create=true, required=true)
      private NavigationBean navBean;

      public void beforePhase(PhaseEvent e) { }

      public void afterPhase(PhaseEvent e) {
      keep(e, e.getFacesContext().getViewRoot().getViewId());
      }

      protected void keep(PhaseEvent e, String viewId) {
      navBean.setCurrentPage(viewId);
      }

      public PhaseId getPhaseId() {
      return PhaseId.RENDER_RESPONSE;
      }
      }

      ###################
      and the annotation of the bean to inject:

      @Name("navBean")
      @Scope(ScopeType.SESSION)
      public class NavigationBean implements Serializable {

      ...


      in all other beans, the injection works fine.
      Both beans are deployed as seam components, but the BijectionInterceptor doesn't work for the KeeperPhaseListener. navBean is null and the required annotation is ignored.

      Thanks for help!