Skip to main content



      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 04:01 Go to next message
Eclipse UserFriend
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 05:41] by Moderator

Re: PhaseListener [message #532845 is a reply to message #532766] Tue, 11 May 2010 06:56 Go to previous messageGo to next message
Eclipse UserFriend
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 11:45 Go to previous message
Eclipse UserFriend
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 11:47] by 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: Sun Aug 31 11:37:14 EDT 2025

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

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

Back to the top