Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Logout
Logout [message #896050] Tue, 17 July 2012 05:22 Go to next message
NkD Missing name is currently offline NkD Missing name
Messages: 61
Registered: July 2009
Member
I have no idea how I can make logout in RAP1.5. Can You kick me ?

In RAP1.4 I have:

public static void logout() {
PhaseListener phaseListener = new PhaseListener() {
@Override
public void beforePhase(PhaseEvent event) {
// nothing
}
@Override
public void afterPhase(PhaseEvent event) {
try {
//hrportal is entry point
RWT.getResponse().getWriter().write(
"parent.window.location.href = \"\\hrportal\";");
} catch (IOException e) {
e.printStackTrace();
} finally {
RWT.getLifeCycle().removePhaseListener(this);
}
}
@Override
public PhaseId getPhaseId() {
return PhaseId.RENDER;
}
};
RWT.getLifeCycle().addPhaseListener(phaseListener);
}

In RAP1.5 and this not work, because JSON.
Re: Logout [message #896051 is a reply to message #896050] Tue, 17 July 2012 05:25 Go to previous messageGo to next message
NkD Missing name is currently offline NkD Missing name
Messages: 61
Registered: July 2009
Member
correction: in RAP1.4 I use:
ContextProvider.getStateInfo().getResponseWriter().write("parent.window.location.href
= \"\\hrportal\";");


Dne 17.7.2012 7:22, Michal NkD Nikodím napsal(a):
> I have no idea how I can make logout in RAP1.5. Can You kick me ?
>
> In RAP1.4 I have:
>
> public static void logout() {
> PhaseListener phaseListener = new PhaseListener() {
> @Override
> public void beforePhase(PhaseEvent event) {
> // nothing
> }
> @Override
> public void afterPhase(PhaseEvent event) {
> try {
> //hrportal is entry point
> RWT.getResponse().getWriter().write(
> "parent.window.location.href = \"\\hrportal\";");
> } catch (IOException e) {
> e.printStackTrace();
> } finally {
> RWT.getLifeCycle().removePhaseListener(this);
> }
> }
> @Override
> public PhaseId getPhaseId() {
> return PhaseId.RENDER;
> }
> };
> RWT.getLifeCycle().addPhaseListener(phaseListener);
> }
>
> In RAP1.5 and this not work, because JSON.
Re: Logout [message #896059 is a reply to message #896051] Tue, 17 July 2012 06:22 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1817
Registered: July 2009
Senior Member
Hi,
use the JSExecutor class instead.
HTH,
Ivan

On 7/17/2012 8:25 AM, Michal NkD Nikodím wrote:
> correction: in RAP1.4 I use:
> ContextProvider.getStateInfo().getResponseWriter().write("parent.window.location.href
> = \"\\hrportal\";");
>
>
> Dne 17.7.2012 7:22, Michal NkD Nikodím napsal(a):
>> I have no idea how I can make logout in RAP1.5. Can You kick me ?
>>
>> In RAP1.4 I have:
>>
>> public static void logout() {
>> PhaseListener phaseListener = new PhaseListener() {
>> @Override
>> public void beforePhase(PhaseEvent event) {
>> // nothing
>> }
>> @Override
>> public void afterPhase(PhaseEvent event) {
>> try {
>> //hrportal is entry point
>> RWT.getResponse().getWriter().write(
>> "parent.window.location.href = \"\\hrportal\";");
>> } catch (IOException e) {
>> e.printStackTrace();
>> } finally {
>> RWT.getLifeCycle().removePhaseListener(this);
>> }
>> }
>> @Override
>> public PhaseId getPhaseId() {
>> return PhaseId.RENDER;
>> }
>> };
>> RWT.getLifeCycle().addPhaseListener(phaseListener);
>> }
>>
>> In RAP1.5 and this not work, because JSON.
>
>

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Logout [message #896506 is a reply to message #896059] Wed, 18 July 2012 15:10 Go to previous messageGo to next message
Ronald So is currently offline Ronald So
Messages: 198
Registered: April 2011
Senior Member
    public static void performLogout() {
        String defaultUrl =
            MessageFormat.format("{0}://{1}:{2}{3}",
                new Object[] { RWT.getRequest().getScheme(),               
                               RWT.getRequest().getServerName(),
                               String.valueOf(RWT.getRequest().getServerPort()),
                               RWT.getRequest().getRequestURI() });
        invalidate(RWT.getSessionStore().getHttpSession());
        String browserText = MessageFormat.format(
                "parent.window.location.href = \"{0}\";", defaultUrl);
        JSExecutor.executeJS(browserText);
    }

    private static void invalidate(final HttpSession session) {
        session.setMaxInactiveInterval(1);

        Thread threadInvalidate = new Thread() {
            public void run() {
                session.invalidate();
            }
        };
        threadInvalidate.start();
    }
Re: Logout [message #896616 is a reply to message #896506] Thu, 19 July 2012 07:24 Go to previous message
NkD Missing name is currently offline NkD Missing name
Messages: 61
Registered: July 2009
Member
thx but I have question. Why do You use threadInvalidate ?

My version is:

public static void logout() {
StringBuilder js = new StringBuilder();
js.append("parent.window.location.href = \"");
js.append(RWT.getRequest().getRequestURL());
int jsessionIndex = js.indexOf(";jsessionid");
if (jsessionIndex != -1) js.setLength(jsessionIndex);
js.append("\";");

JSExecutor.executeJS(js.toString());

HttpSession session = RWT.getSessionStore().getHttpSession();
session.setMaxInactiveInterval(1);
session.invalidate();
}

and it looks like it works



Dne 18.7.2012 17:10, Ronald So napsal(a):
>
> public static void performLogout() {
> String defaultUrl =
> MessageFormat.format("{0}://{1}:{2}{3}",
> new Object[] { RWT.getRequest().getScheme(),
> RWT.getRequest().getServerName(),
>
> String.valueOf(RWT.getRequest().getServerPort()),
> RWT.getRequest().getRequestURI() });
> invalidate(RWT.getSessionStore().getHttpSession());
> String browserText = MessageFormat.format(
> "parent.window.location.href = \"{0}\";", defaultUrl);
> JSExecutor.executeJS(browserText);
> }
>
> private static void invalidate(final HttpSession session) {
> session.setMaxInactiveInterval(1);
>
> Thread threadInvalidate = new Thread() {
> public void run() {
> session.invalidate();
> }
> };
> threadInvalidate.start();
> }
>
Previous Topic:Trouble with RAP & Spring
Next Topic:Eclipse 3.8/rap 1.5 helpSystem problem
Goto Forum:
  


Current Time: Mon Sep 22 10:26:34 GMT 2014

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

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