It's not a secret anymore!*
The moose likes JSF and the fly likes Hooking Beans Based on Scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Hooking Beans Based on Scope" Watch "Hooking Beans Based on Scope" New topic
Author

Hooking Beans Based on Scope

Dennis Hopfer
Ranch Hand

Joined: Dec 02, 2010
Posts: 43
Can we hook beans so that when they are about to go out of scope that we can name a callback function to be executed first?

Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

Not beans themselves, no. A bean is something that can (in theory) be a member of more than one collection, although obviously putting a bean in both the session and request collections is a little silly. What you can do, however, is set up a listener to the collection itself. For example, when the session is destroyed, a session listener is a clue that all the beans in the session are going out of scope, since the scope itself is being destroyed. Beans don't just evaporate, so that's usually sufficient unless you have code that's manually inserting/removing beans.


Customer surveys are for companies who didn't pay proper attention to begin with.
Dennis Hopfer
Ranch Hand

Joined: Dec 02, 2010
Posts: 43
Thanks Tim. Is this the class I should be messing with:

http://download.oracle.com/javaee/6/api/javax/servlet/http/HttpSessionListener.html


Appears someone else was using it over here:

http://www.coderanch.com/t/210736/JSF/java/HttpSessionListener-JSF-App
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

Yep. It's popular for that kind of stuff.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hooking Beans Based on Scope
 
Similar Threads
correct usage of: controller nocache="true"/
What is the use of jsp:useBean tag ?.
Instantiating a Bean in Spring
jsp:include
Doubt in objects scope in JSP