Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » PhaseListener(a phaselistener is added to the lifecycle class and saved in application scope, not in session scope.)
PhaseListener [message #532766] Tue, 11 May 2010 08:01 Go to next message
lsq  is currently offline lsq Friend
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 #532845 is a reply to message #532766] Tue, 11 May 2010 10:56 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
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.
Re: PhaseListener [message #532945 is a reply to message #532845] Tue, 11 May 2010 15:45 Go to previous message
lsq  is currently offline lsq Friend
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

Previous Topic:CCombo in CellEditor can not be set "not editable" any longer
Next Topic:fail to access application server from inside war
Goto Forum:
  


Current Time: Fri Dec 13 13:06:34 GMT 2024

Powered by FUDForum. Page generated in 0.03187 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top