wood burning stoves
The moose likes JSF and the fly likes JSF sessionScope and storing values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF sessionScope and storing values" Watch "JSF sessionScope and storing values" New topic

JSF sessionScope and storing values

Akshat Joshi

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.

Akshat Joshi

Joined: Jun 28, 2010
Posts: 4
Anyone...any thoughts? :/
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: JSF sessionScope and storing values
It's not a secret anymore!