File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Looking for an idea to call action listner or other way to call java code from link(not commandlink)

 
Daniel Reznick
Ranch Hand
Posts: 50
Eclipse IDE Google App Engine jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I'm building some project on JSF2

and i got a sign out button which i want to invalidate the session when its clicked...

i cant do a redirect to a jsp... its a "special" link that does the log out , so i cant use the link for the session invalidation

I dont want to use commandLink cause i need to put it into a form, and i don't to make my code uglier...


any ideas?

Im using JSF 2 (new to it)
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried invalidating the session in java code, but until unless your in JSF life cycle a new session is recreated.
Guys correct me if I am wrong, because I faced this problem so what I did is used javascript to forcibly come out of the life cycle and invalidated the session in a jsp file and closed the page.

might be this information is helpful to think other way around.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17641
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session != login.

JSF tends to make this very obvious. JSF creates sessions early, since it's so dependent on session-scope objects for things like datatables.

You still log out by invalidating a session. The best way to do that is to code an action method with the "immediate" attribute on the invoking commandButton/commandLink. That will delete the current session and log you out. You then specify where to navigate to on exit from the action method in the usual way.

If the next view to be presented requires session-scope objects, a new session will be created. However that won't be a logged-in session until you actually log back in again.

If your next view is a simple page with a "You have been logged out" message and maybe a "Click Here" to login, you can avoid creating new session objects and that will keep you from cluttering your server with orphaned sessions. On the other hand, if your logout redirects to a public home page with session object references on it, you'll have to endure the fact that people could then leave the site and the orphaned session would linger until the session timeout interval had expired.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic