Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSF and the fly likes how to remove an object from session with JSF 2.0 + Facelets?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "how to remove an object from session with JSF 2.0 + Facelets??" Watch "how to remove an object from session with JSF 2.0 + Facelets??" New topic
Author

how to remove an object from session with JSF 2.0 + Facelets??

vishnu bola
Ranch Hand

Joined: Jun 01, 2009
Posts: 32
hi all,

I have a facelets page which calls a backing bean of session scope. Now when ever i click on this page i want the existing bean object to be removed from the session . In my existing jsp i have a logic something like this to remove the object from session




Now i have to refactor my jsp to use facelets and i should not be using scriplets anymore . I did try with JSTL but the <c:remove> tag is not supported by facelets.

Can someone help me how can i refactor this code to work for my facelets?

I really appreciate your help in advance

Thank you
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14491
    
    7

In the action processor for your submit (commandButton), get the FacesContext and chase down through it to get the HttpSession object, then remove the attribute in the usual manner. I maintain a separate JSF utilities class for functions like this, to keep the app code simpler and easier to test offline.

JSF2 has introduced other ways to control the lifespan of a backing bean, but all the examples I've seen so far have been pretty wretched. Fortunately, the View Scope is an exception if you can use it.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to remove an object from session with JSF 2.0 + Facelets??
 
Similar Threads
communication between 2 session beans
removeAttribute() question
ManagedBeanCreation, JSF, and ClassLoading
c:import with Facelets
Is there any person worked on HashMap and Session