PhaseListener [message #532766] |
Tue, 11 May 2010 08:01 |
lsq Messages: 40 Registered: July 2009 |
Member |
|
|
Hi all,
I took a look at the rap implementation. It seems that a phase listener is added to the global lifecycle instance and becomes visible to every session before it is removed. If I am right, can I have a phaselistener that is applicable only to its original session without doing any additional checkings? If not are there any other options? It seems to me that a customized service handler implementation is also gloablly visible.
To be short, are there any ways in RAP like JSFace or other framework, people can intervene different phases of the request cycle in the local session without affecting other sessions?
p.s., is a good idea if phase listeners are saved in the session scope?
Many thanks.
[Updated on: Tue, 11 May 2010 09:41] Report message to a moderator
|
|
|
|
Re: PhaseListener [message #532945 is a reply to message #532845] |
Tue, 11 May 2010 15:45 |
lsq Messages: 40 Registered: July 2009 |
Member |
|
|
Stefan Röck wrote on Tue, 11 May 2010 06:56 | Hi,
yes, you're right. To execute code for a specific session, a common
pattern is to keep display instance and compare it with
Display.getCurrent() within the phase listener implementation. This
works as a display has a 1:1 relation with a session.
Also don't forget to remove the listener afterwards. Here's a snippet:
final Display display = Display.getCurrent();
RWT.getLifeCycle().addPhaseListener(new PhaseListener(){
public void afterPhase(PhaseEvent event){
if (display == Display.getCurrent()) {
try {
// TODO:
} finally {
RWT.getLifeCycle().removePhaseListener(this);
}
}
}
public void beforePhase(PhaseEvent event){
}
public PhaseId getPhaseId(){
return PhaseId.RENDER; //TODO: replace with desired phase
}
});
Regards,
Stefan.
lsq schrieb:
> Hi all,
>
> I took a look at the rap implementation. It seems that a phase listener
> is added to the global lifecycle instance and becomes visible to every
> session before it is removed. If I am right, can I have a phaselistener
> that is applicable only to its original session without doing any
> additional checkings? If not are there any other options? It seems to me
> that a customized service handler implementation is also gloablly visible.
>
> To be short, are there any ways in RAP like JFace or other framework,
> people can intervene different phases of the request cycle in the local
> session without affecting other sessions?
>
> Many thanks.
|
hi,
the snippet will work for most of the scenarios, while an explicit session-scoped phase listener is more desirable when a fine control over all phases when processing a request is required.
Regards,
lsq
[Updated on: Tue, 11 May 2010 15:47] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03187 seconds