• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 50
jQuery Eclipse IDE Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 121
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic