| Author |
JSF sessionScope and storing values
|
Akshat Joshi
Greenhorn
Joined: Jun 28, 2010
Posts: 4
|
|
Just a doubt regarding how JSF session management works
I got a managedbean as :
So now since the bean is sessionScoped, will JSF store my "userBO" object in the session too? Or do I have to declare "userBO" as transient so that it is ignored?
I believe that variables with both the setters and getters are likely to be stored in the session. Correct me if I am wrong.
Thanks
|
 |
Akshat Joshi
Greenhorn
Joined: Jun 28, 2010
Posts: 4
|
|
|
Anyone...any thoughts? :/
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14472
|
|
First thought: Have Patience. We're not paid to sit here 24x7, so it can take a day or 2 to get an answer. It's the down side of free help.
Second thought: Standarddisclaimerthatuser-createdloginsareBAD. I rant about this often enough, I'll spare people a repeat. Please consider using J2EE standard Form-based logins instead.
Now the Real Answer.
There is no "userBO" object created by this bean. The value "#{userBO}" is a Unified Expression Language predicate. In other words, it's an expression in EL that references a Java object that was defined in the EL dictionary under the name of "userBO". When applied to a ManagedProperty annotation, it provides the JSF bean manager with a reference to a bean to inject. You have to construct and define userBO to the EL system yourself in an external definition. Typically that means either defining UserBO as a ManagedBean itself via its own annotations or a faces-config.xml definition, but other sources such as the Spring Framework can also supply named beans that EL can reference, too.
Java has no implied accessor/mutator mechanism, and it is not recommended that Managed Bean properties (or for that matter, any POJO properties) be declared as public. So you must manually create the required set/get methods. Fortunately, most IDEs have a "one-button" mechanism to construct the necessary Java code automatically.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: JSF sessionScope and storing values
|
|
|