• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Using FacesCcntext within Listeners and Filters

 
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it okay to use FacesContext within Listeners or filters in order to retrieve the Http Request Object?
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the case of a listener (Action- or ValueChange), the answer is yes...FacesContext can be accessed by calling the static getCurrentInstance method: FacesContext.getCurrentInstance(). FacesContext essentially represents the request as it travels through the JSF lifecycle.

I am guessing (but I'm not sure) that the same does not apply to filters. Although the request itself is available, FacesServlet may not have instantiated FaceContext yet. But you can get at the HttpRequest object in the filter, because it is a parameter passed into the doFilter method (OK, it's passed as a ServletRequest, but can be cast, if I'm not mistaken).
 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know it can be accessed but the question is is it appropriate to obtain the request object in a (Listener/Filter) using a FacesContext
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic