aspose file tools*
The moose likes JSF and the fly likes Looking for an idea to call action listner or other way to call java code from link(not commandlink) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Looking for an idea to call action listner or other way to call java code from link(not commandlink)" Watch "Looking for an idea to call action listner or other way to call java code from link(not commandlink)" New topic
Author

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

Daniel Reznick
Ranch Hand

Joined: Oct 23, 2008
Posts: 50

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

Joined: Oct 05, 2009
Posts: 121

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.


Sun Certified Java Programmer with 93 percent
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Looking for an idea to call action listner or other way to call java code from link(not commandlink)
 
Similar Threads
assigning parameters at runtime
Richfaces SuggestionBox Bug on select an item
Download files component
JSF faces-redirect not working
How to create a secure login system?