Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JSF sessionScope and storing values  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone...any thoughts? :/
 
Bartender
Posts: 19658
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!