I need to persist just one object in session scope of my JSF application. Where do I define a session variable, and how do I get and set it from either a view file or backing bean?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Two general ways:
Store it in
ExternalContext#getSessionMap()And then later:
Or, make it a property of a
@SessionScopedbean which you inject in your@RequestScopedbean.And then later:
You can get a
@Named @SessionScopedinto a@Named @RequestScopedvia@Inject.Or, if you’re not using CDI yet, you can get a
@ManagedBean @SessionScopedinto a@ManagedBean @RequestScopedvia@ManagedProperty.