File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

JSF 2 Session Scope & Class level properties.

Aakash Saxena
Greenhorn

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

@ManagedBean(name="TableDisplayBean")
@SessionScoped

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.


Thanks


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

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
Greenhorn

Joined: Nov 11, 2012
Posts: 13
Thanks a lot Tim, I'll take care of the coding standards you referred to.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF 2 Session Scope & Class level properties.
 
Similar Threads
selectManyCheckbox in dataTable returns only the last selected item rather the whole list.
Validation error while trying to change a value in a request scope bean
Unwanted behavior: Action method being called several times
Argument Error: One or more parameters are null.
Problems using h:selectOneMenu