• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling requests in Session scoped backing bean

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
given the comments below.....
 
Nandakumar Rajamanickam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No techies to answer my question?
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic