This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling requests in Session scoped backing bean

 
Nandakumar Rajamanickam
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Techies, In our JSF design for portal, we have made a design such a way to have all the backing beans in session scope [for many a reasons]. But in the same page, if I have multiple actions, then I need to differentiate one request from the other. Please let me know how to do this in the proper way [since constructor of backing bean called only once if it is in session scope....]. I am thinking of having a init kind of method in the JSP and get the request value through f:param. is my thought, correct?

Let me know if my question is not clear.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, you can obtain the HttpServletRequest object through the FacesContext within a backing bean. So, if you do that, you can gain access to the reques object, even if the backing bean is in Session scope. Would that do?

-Cameron McKenzie
 
Nandakumar Rajamanickam
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
given the comments below.....
 
Nandakumar Rajamanickam
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Problem is not in getting hold of the request object. Instead to reinitialize the class level variables on every request if it is required.

What I am currently doing is, write one dummy method in the backing bean and call it in the top of the JSP page. Inside that method reinitialize the variables. It works perfectly fine but I want to know whether any other better way of doing this.
 
Nandakumar Rajamanickam
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No techies to answer my question?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17620
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is very unfortunate that your design has limited itself. There's a good reason that backing beans come in more than one scope, and for my own part, I'd prefer that less of my backing beans were session scope, for scalability reasons.

Although you can define multiple actions on a JSF view, only one of them can fire per rquest/response cycle. So that's not an issue. However, it sounds more like you're looking to detect a "first view only" behavior of the JSF page. Try searching this forum and you might find something useful.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic