You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mike Duffy <md...@yahoo.com> on 2006/01/18 19:04:31 UTC

PhaseListener

Is it possible to implement a PhaseListener on a backing bean?  I tried to do this but could not
get it to work.

I'd like to be able to trace the phases as a page loads.  Is there some standard way to know what
phase of the component life cycle has been activated?

Thx.

Mike

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: PhaseListener

Posted by Simon Kitching <sk...@apache.org>.
On Wed, 2006-01-18 at 10:04 -0800, Mike Duffy wrote:
> Is it possible to implement a PhaseListener on a backing bean?  I tried to do this but could not
> get it to work.
> 
> I'd like to be able to trace the phases as a page loads.  Is there some standard way to know what
> phase of the component life cycle has been activated?
> 

I do this by implementing an independent class as the phase listener.
When a phase callback occurs, it stores the current phase in a static
ThreadLocal variable. A single HTTP request is always serviced in a
single thread, so this works nicely. A static method is then provided
for any code that wants to query the current phase (for the current
thread):
  String phaseId = PhaseTracker.getCurrentPhase();

Regards,

Simon



Re: PhaseListener

Posted by Aleksei Valikov <va...@gmx.net>.
Hi.

> Is it possible to implement a PhaseListener on a backing bean?  I tried to do this but could not
> get it to work.
> 
> I'd like to be able to trace the phases as a page loads.  Is there some standard way to know what
> phase of the component life cycle has been activated?

What I did was implementing a small PhaseListener which dispatches phase 
events among session attributes. Works fine for me. I simply implement 
PhaseListener in my session-scoped bean and it gets notified about 
phases. The same could be done for page and application context, I only 
needed that for the session context.

Source code attached.

Bye.
/lexi