aspose file tools*
The moose likes JSF and the fly likes Handling requests in Session scoped backing bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Handling requests in Session scoped backing bean" Watch "Handling requests in Session scoped backing bean" New topic
Author

Handling requests in Session scoped backing bean

Nandakumar Rajamanickam
Greenhorn

Joined: May 27, 2009
Posts: 5
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

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: May 27, 2009
Posts: 5
given the comments below.....
Nandakumar Rajamanickam
Greenhorn

Joined: May 27, 2009
Posts: 5
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

Joined: May 27, 2009
Posts: 5
No techies to answer my question?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling requests in Session scoped backing bean