Matt Tyson wrote:
If I'm following you here, then you'd have a phase listener (call it
'listenerLoader') that basically instantiates the managedbean that will in
turn become a phase listener itself?

Seems like it should work...

Could do. The original phase listener could then remove itself.

I have been thinking of a more general solution: an "eager bean loader" servlet context listener that somehow determines a list of managed bean names to load, and instantiates them on webapp startup. It would then be possible to write a standard class that uses
  LifecycleFactory.getLifecycle(id).addPhaseListener(this)
in its constructor to register itself on startup, rather than listing it in a <listener> tag.

One problem with this is that the "eager bean loader" needs to instantiate the objects which means doing something like:
  NeededBean neededBean
    = (NeededBean) facesContext.getApplication()
      .getVariableResolver().resolveVariable(facesContext,
        "neededBean");
which means creating a FacesContext instance when there is no ServletRequest/ServletResponse available which means mocking up instances of them.


Regards,

Simon

Reply via email to