Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to redirect to a logout page(How to redirect to a logout page)
How to redirect to a logout page [message #822526] Fri, 16 March 2012 19:52 Go to next message
Luis Carlos Moreira da Costa is currently offline Luis Carlos Moreira da CostaFriend
Messages: 39
Registered: July 2009
Location: Brazil
Member

@Override
public void postShutdown() {
super.postShutdown();
final Display display = Display.getCurrent();
RWT.getLifeCycle().addPhaseListener(new PhaseListener() {

private static final long serialVersionUID = 1L;

public void afterPhase(final PhaseEvent event) {
if(Display.getCurrent() == null || display == Display.getCurrent()) {
try {
// Uses a non-public API, but currently this is the only solution
//HtmlResponseWriter writer = ContextProvider.getStateInfo().getResponseWriter();
final PrintWriter writer = RWT.getResponse().getWriter();





final String url = "html/logout.html";
writer.write("window.location.href=\'" + url + "\';");


RWT.getRequest().getSession().setMaxInactiveInterval(1);
} catch(final IOException e) {
e.printStackTrace();
}
RWT.getLifeCycle().removePhaseListener(this);
}
}

public PhaseId getPhaseId() {
return PhaseId.ANY;
}

public void beforePhase(final PhaseEvent event) {
};
});
}


Luís Carlos Moreira da Costa
Eclipse RAP, RCP, eRCP, GEF, EMF, GMF, OSGI, Spring-DM and Pentaho Developer
Regional Communities/Brazil
http://wiki.eclipse.org/Regional_Communities/Brazil
Re: How to redirect to a logout page [message #822529 is a reply to message #822526] Fri, 16 March 2012 20:29 Go to previous messageGo to next message
Elias Volanakis is currently offline Elias VolanakisFriend
Messages: 26
Registered: July 2009
Junior Member
Hi Luis,

can you explain what you are trying to do? This will make it easier to answer.

If I guess: you want to invalidate the session and log the user out? I.e. something like a log-out button? Is that correct?

Thanks,
Elias.


Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis
Re: How to redirect to a logout page [message #822530 is a reply to message #822529] Fri, 16 March 2012 20:31 Go to previous messageGo to next message
Luis Carlos Moreira da Costa is currently offline Luis Carlos Moreira da CostaFriend
Messages: 39
Registered: July 2009
Location: Brazil
Member

I.e. something like a log-out button

Luís Carlos Moreira da Costa
Eclipse RAP, RCP, eRCP, GEF, EMF, GMF, OSGI, Spring-DM and Pentaho Developer
Regional Communities/Brazil
http://wiki.eclipse.org/Regional_Communities/Brazil
Re: How to redirect to a logout page [message #822536 is a reply to message #822530] Fri, 16 March 2012 21:10 Go to previous messageGo to next message
Elias Volanakis is currently offline Elias VolanakisFriend
Messages: 26
Registered: July 2009
Junior Member
Hi Luis,

Your approach: session.setMaxInterval(1) is a good idea. However the PhaseListener is not appropriate (it gets called on every request!). Here is an example that uses a clickable "Logout" link.

Hope this helps,
Elias.


Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis
Re: How to redirect to a logout page [message #822537 is a reply to message #822536] Fri, 16 March 2012 21:15 Go to previous messageGo to next message
Luis Carlos Moreira da Costa is currently offline Luis Carlos Moreira da CostaFriend
Messages: 39
Registered: July 2009
Location: Brazil
Member

But if it was on a toolbar for the User click out

Luís Carlos Moreira da Costa
Eclipse RAP, RCP, eRCP, GEF, EMF, GMF, OSGI, Spring-DM and Pentaho Developer
Regional Communities/Brazil
http://wiki.eclipse.org/Regional_Communities/Brazil
Re: How to redirect to a logout page [message #822539 is a reply to message #822537] Fri, 16 March 2012 21:25 Go to previous messageGo to next message
Luis Carlos Moreira da Costa is currently offline Luis Carlos Moreira da CostaFriend
Messages: 39
Registered: July 2009
Location: Brazil
Member

"html/logout.html";

Luís Carlos Moreira da Costa
Eclipse RAP, RCP, eRCP, GEF, EMF, GMF, OSGI, Spring-DM and Pentaho Developer
Regional Communities/Brazil
http://wiki.eclipse.org/Regional_Communities/Brazil
Re: How to redirect to a logout page [message #822540 is a reply to message #822539] Fri, 16 March 2012 21:34 Go to previous message
Elias Volanakis is currently offline Elias VolanakisFriend
Messages: 26
Registered: July 2009
Junior Member
Hi Luis,

you would need to register that file first. See:

wiki.eclipse.org/RAP/FAQ#How_to_register_a_file.2Ffolder_as_resource.3F

Elias.


Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis
Previous Topic:Access the UI Thread in an ElementFactory
Next Topic:setIcon NullPointerException
Goto Forum:
  


Current Time: Thu Apr 25 11:18:02 GMT 2024

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

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

Back to the top