aspose file tools*
The moose likes JSF and the fly likes Calling a backing bean method with no user input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Calling a backing bean method with no user input" Watch "Calling a backing bean method with no user input" New topic
Author

Calling a backing bean method with no user input

scott gaidos
Greenhorn

Joined: Jan 30, 2002
Posts: 6
I have a session scope backing bean that I want to use for security authentication and authorization.

How can I invoke the methods on the bean from a JSP with no user interaction?
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
All session scoped backing bean resides in the session of course. You can directly retrieve these beans as you normally do with session attributes, provided you know the id of the backing bean.


SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
In case you decide you want to do it inside of a backing bean:

I beleive that's how you do it... there might be some mistakes but that's the general idea.
Sergey Smirnov
Ranch Hand

Joined: May 29, 2003
Posts: 167
Just be careful with getting a reference to the managed bean from the session map directly. It might not be there yet. Managed Bean has a lazy initialization. It means the session scope managed bean is initialized and put in the session bean not at the moment the session is created, but when the managed bean is first time referenced.

This following code returns the reference to the managed bean and create it if it is not in the session map yet:



--
Sergey : http://jsfTutorials.net
[ March 19, 2006: Message edited by: Sergey Smirnov ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

Actually, by definition, a session-scoped object is ultimately the result of a user interaction. Where and how, of course, is the question.

Now if you want something to exist "before" anyone interacts, you'd use appliaction scope, instead.

Note that "before" may be an extremely short period of time, depending on who lazily the app initiailizes its contexts.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: Calling a backing bean method with no user input