This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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
  • 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
  • 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: 22482
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • 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 can't take it! You are too smart for me! Here is the tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic