The moose likes JSF and the fly likes What is the use of  Facescontext Context Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "What is the use of  Facescontext Context Object" Watch "What is the use of  Facescontext Context Object" New topic

What is the use of Facescontext Context Object

shivakumar paka

Joined: Mar 05, 2008
Posts: 15
Please explain me where the FacesContext Object exactly will be used?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952

Ideally, as little as possible.

The Facescontext is the anchor point for connecting to framework-and container- specific services. For example, you can obtain the underlying httprequest and context objects for the page request that's accessing your backing bean by going through the Facescontext. That includes the security context a web page request is running under.

The general philosophy behind JSF is that the user-provided components should be abstract enough not to depend on such details as to whether they're running in a traditional JSP environment or something more exotic, so if there's a Facescontext reference in the bean, it's a potential sign of bad design, especially since beans are expected to have things injected into them, not go out looking for stuff.

However, sometimes for one reason or another, it's convenient to reach out of the backing bean and obtain the outlying information, so it's there if you need it.

Customer surveys are for companies who didn't pay proper attention to begin with.
Consider Paul's rocket mass heater.
subject: What is the use of Facescontext Context Object
Similar Threads
how to access faces context and backing beans in a servlet filter
how to access a session value on JSF page?
[Resolved] Services as Managed Beans
Validation For Tomahawk inputCalender Component
Is FacesContext an object for entire aplication, or it's instantiated for each jsf page?