On 4/28/06, 王曾wang_zeng <[EMAIL PROTECTED]> wrote:
2006/4/29, Craig McClanahan <[EMAIL PROTECTED]>: > > You also have to remember that your listener is going to receive > beforePhase() calls for *all* simultaneously active requests, not just the > one page you might be interested in. And, don't forget to deregister > yourself as a listener when the request completes, so you don't create a > memory leak. > The Faces servlet acts like the Action servlet, and every request goes to it to go through the 6-phase lifecycle before they are forwarded to the JSP. Is that the reason why my listener receives beforePhase() calls for *all* simultaneously active requests?
Nor really. The actual reason is that the object you are adding your listener to (the Lifecycle implementation for this webapp) is an application-wide singleton. It's execute() and render() methods are the ones that actually trigger the events, and they are called for all requests. I should also note that JSF 1.2 adds a significant simplification for phase listeners ... you can attach per-view listeners by registering them with the UIViewRoot at the base of the component tree for this particular view, and a lot of the complexity described above gets reduced. Craig