Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF 2 Session Scope & Class level properties.

 
Aakash Saxena
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18304
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aakash Saxena
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Tim, I'll take care of the coding standards you referred to.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic