The moose likes JSF and the fly likes JSF 2 Session Scope & Class level properties. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSF
Bookmark "JSF 2 Session Scope & Class level properties." Watch "JSF 2 Session Scope & Class level properties." New topic

JSF 2 Session Scope & Class level properties.

Aakash Saxena

Joined: Nov 11, 2012
Posts: 13
Hi All

I am currently working in a project wherein I am using jsf 2.

I have defined lot of class level properties in my managed bean as shown below


public class DetailedDisplayBean extends AbstractHandler {

private String execute;
private String TabHTMLContent;
public String invokingApplication;
public String rowCount;
public TableVO tableVO;
public List<TableVO> listOfTables;
public HtmlDataTable table;
private TableInputVO inputVO;
private TableOutputVO outputVO;
private List<SelectItem> listOfSelectItems = new ArrayList<SelectItem>();
private String messageForErrorPage;

I use all these properties to show the values on front-end.

As fas as I know, having class level properties may create concurrency issues when multple users use application
But since the scope type of my manged bean is SESSION, I am assuming that all these class level properties are bound to the session and so each user accessing the application will have his own copy of these properties bound to his/her session. Thus there will be no concurrency issues.

Please correct me if I am wrong ?

Just to tell you, the data that will be saved in session is very small in size and so i don't foresee any performance issues.


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17023

You are correct. Each user has a unique instance of beans declared in session scope and will not interfere with any other user.

Aside from that, however, I must pick a few nits. First, the name of a Managed Bean should not begin uppercase. The convention is that instance names begin lower-case, class names begin upper-case. Secondly, a backing bean is a Model, not a Controller (which is what I interpret "Handler" to mean). Failure to observe these nuances usually won't hurt, but it's better to be careful.

Customer surveys are for companies who didn't pay proper attention to begin with.
Aakash Saxena

Joined: Nov 11, 2012
Posts: 13
Thanks a lot Tim, I'll take care of the coding standards you referred to.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: JSF 2 Session Scope & Class level properties.
It's not a secret anymore!