[Wicket-user] Logging Out (What to do with the session)

2007-04-24 Thread Francisco Diaz Trepat - gmail

Hello everyone, I was wondering for a proper way to handle sessions and
logging in and out of a wicket application in general.

The thing is as follows.

I have a Session called WicketSession, inside of which I use a CORBA
BUISINESS object labeled m_cSession to do a Login.

WicketSession has the following two methods:

  /**
   * Terminates the logged user for this Session.
   */
  public void logout() {
 //Verify user isn't logged out already
 if (!m_bUserLoggedIn) {
return;
 }
 //Execute a logout
 try {
m_cSession.logout();
m_bUserLoggedIn = false;
m_cSessionLocale = Locale.getDefault();
 }
 catch (Exception xException) {
m_bUserLoggedIn = false;
m_cSessionLocale = Locale.getDefault();
 }
  }

  /**
   * Initiates logged user for this Session.
   */
  public void login(String sUserId, String sUserPassword) {
 //Verify input data and that the user isn't logged in already
 if (m_bUserLoggedIn || sUserId == null || sUserPassword == null) {
m_bUserLoggedIn = false;
return;
 }
 //Execute a login
 try {
//create a session
m_cSession = new ch.logismata.serverwrapper.Session();
//set user and password
m_cSession.setId(sUserId);
m_cSession.setPassword(sUserPassword);
//Execute and verify login
if (m_cSession.login() != null) {
   m_bUserLoggedIn = true;
}
 } catch (Exception xException) {
m_bUserLoggedIn = false;
 }
  }


...

Very plain. The thing is this, Session also maintains certain state already
in wicket, and a question was:

Should I invalidate the session? If I do, can I redirect the user to a Home
Page where he would get a new session going-on?

Is this a proper approach?

Usually when I close the Tab on my Firefox and I Call to the site, the
Session is also remembered as the Locale is maintain as that of the last
state (before I close the tab).

Why is this?

Sorry if my questions may feel sordid.

f(t)
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Logging Out (What to do with the session)

2007-04-24 Thread Igor Vaynberg

yes i would invalidate the session:

onclick() {
  final string url=urlfor(HomePage.class);
  getsession().invalidate();
  getrequestcycle().pushTarget(new RedirectRequestTarget(url));
}

something like that

-igor


On 4/24/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED]
wrote:


Hello everyone, I was wondering for a proper way to handle sessions and
logging in and out of a wicket application in general.

The thing is as follows.

I have a Session called WicketSession, inside of which I use a CORBA
BUISINESS object labeled m_cSession to do a Login.

WicketSession has the following two methods:

   /**
* Terminates the logged user for this Session.
*/
   public void logout() {
  //Verify user isn't logged out already
  if (!m_bUserLoggedIn) {
 return;
  }
  //Execute a logout
  try {
 m_cSession.logout();
 m_bUserLoggedIn = false;
 m_cSessionLocale = Locale.getDefault();
  }
  catch (Exception xException) {
 m_bUserLoggedIn = false;
 m_cSessionLocale = Locale.getDefault();
  }
   }

   /**
* Initiates logged user for this Session.
*/
   public void login(String sUserId, String sUserPassword) {
  //Verify input data and that the user isn't logged in already
  if (m_bUserLoggedIn || sUserId == null || sUserPassword == null) {
 m_bUserLoggedIn = false;
 return;
  }
  //Execute a login
  try {
 //create a session
 m_cSession = new ch.logismata.serverwrapper.Session();
 //set user and password
 m_cSession.setId(sUserId);
 m_cSession.setPassword(sUserPassword);
 //Execute and verify login
 if (m_cSession.login() != null) {
m_bUserLoggedIn = true;
 }
  } catch (Exception xException) {
 m_bUserLoggedIn = false;
  }
   }


...

Very plain. The thing is this, Session also maintains certain state
already in wicket, and a question was:

Should I invalidate the session? If I do, can I redirect the user to a
Home Page where he would get a new session going-on?

Is this a proper approach?

Usually when I close the Tab on my Firefox and I Call to the site, the
Session is also remembered as the Locale is maintain as that of the last
state (before I close the tab).

Why is this?

Sorry if my questions may feel sordid.

f(t)

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Logging Out (What to do with the session)

2007-04-24 Thread Francisco Diaz Trepat - gmail

Off the top of your head again?

¬_¬ (me needs that head).

Great thanks.

On 4/24/07, Igor Vaynberg [EMAIL PROTECTED] wrote:


yes i would invalidate the session:

onclick() {
   final string url=urlfor(HomePage.class);
   getsession().invalidate();
   getrequestcycle().pushTarget(new RedirectRequestTarget(url));
}

something like that

-igor


On 4/24/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED]
wrote:

 Hello everyone, I was wondering for a proper way to handle sessions and
 logging in and out of a wicket application in general.

 The thing is as follows.

 I have a Session called WicketSession, inside of which I use a CORBA
 BUISINESS object labeled m_cSession to do a Login.

 WicketSession has the following two methods:

/**
 * Terminates the logged user for this Session.
 */
public void logout() {
   //Verify user isn't logged out already
   if (!m_bUserLoggedIn) {
  return;
   }
   //Execute a logout
   try {
  m_cSession.logout();
  m_bUserLoggedIn = false;
  m_cSessionLocale = Locale.getDefault();
   }
   catch (Exception xException) {
  m_bUserLoggedIn = false;
  m_cSessionLocale = Locale.getDefault();
   }
}

/**
 * Initiates logged user for this Session.
 */
public void login(String sUserId, String sUserPassword) {
   //Verify input data and that the user isn't logged in already
   if (m_bUserLoggedIn || sUserId == null || sUserPassword == null) {
  m_bUserLoggedIn = false;
  return;
   }
   //Execute a login
   try {
  //create a session
  m_cSession = new ch.logismata.serverwrapper.Session();
  //set user and password
  m_cSession.setId(sUserId);
  m_cSession.setPassword(sUserPassword);
  //Execute and verify login
  if (m_cSession.login() != null) {
 m_bUserLoggedIn = true;
  }
   } catch (Exception xException) {
  m_bUserLoggedIn = false;
   }
}


 ...

 Very plain. The thing is this, Session also maintains certain state
 already in wicket, and a question was:

 Should I invalidate the session? If I do, can I redirect the user to a
 Home Page where he would get a new session going-on?

 Is this a proper approach?

 Usually when I close the Tab on my Firefox and I Call to the site, the
 Session is also remembered as the Locale is maintain as that of the last
 state (before I close the tab).

 Why is this?

 Sorry if my questions may feel sordid.

 f(t)


 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user



-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Logging Out (What to do with the session)

2007-04-24 Thread Eelco Hillenius
 onclick() {
final string url=urlfor(HomePage.class);
getsession().invalidate();
getrequestcycle().pushTarget(new
 RedirectRequestTarget(url));
 }

Or just

onClick() {
  Session.get().invalidate(); // invalidated after the request is handled
  setResponsePage(Home.class);
}

This works for sure when your home page is stateless (and bookmarkable
of course). And I think it should work in other cases as well. If not,
you can try Session.get().invalidateNow();

Eelco

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Logging Out (What to do with the session)

2007-04-24 Thread Francisco Diaz Trepat - gmail

Great, both of them worked.

Only this:

getRequestCycle().setRequestTarget(new RedirectRequestTarget(url));



On 4/24/07, Eelco Hillenius [EMAIL PROTECTED] wrote:


 onclick() {
final string url=urlfor(HomePage.class);
getsession().invalidate();
getrequestcycle().pushTarget(new
 RedirectRequestTarget(url));
 }

Or just

onClick() {
  Session.get().invalidate(); // invalidated after the request is handled
  setResponsePage(Home.class);
}

This works for sure when your home page is stateless (and bookmarkable
of course). And I think it should work in other cases as well. If not,
you can try Session.get().invalidateNow();

Eelco

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Logging Out (What to do with the session)

2007-04-24 Thread Eelco Hillenius
 Great, both of them worked.

 Only this:

 getRequestCycle().setRequestTarget(new
 RedirectRequestTarget(url));

What do you mean?

Eelco

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Logging Out (What to do with the session)

2007-04-24 Thread Francisco Diaz Trepat - gmail

In the message that I sent I am sure that the text that Igor sent was
included.

if not here it is:

Igor Vaynberg wrote::
onclick() {
  final string url=urlfor(HomePage.class);
  getsession().invalidate();
  getrequestcycle().pushTarget(new RedirectRequestTarget(url));
}

Only this:
getRequestCycle().setRequestTarget(new RedirectRequestTarget(url));

Instead of this:
getrequestcycle().pushTarget

That is what I meant.

On 4/24/07, Eelco Hillenius [EMAIL PROTECTED] wrote:


 Great, both of them worked.

 Only this:

 getRequestCycle().setRequestTarget(new
 RedirectRequestTarget(url));

What do you mean?

Eelco

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user