how to use FacesContext in JSF? please give me one whole example ? and some explantion when and at what condition we need to use this?
+4
A:
FacesContext
gives you access to multiple useful contexts and objects, like:
- the
Application
object, containing application-related 'settings' - the external context, which is in most cases the
ServletContext
- Various JSF UI objects, like the render kit, the
UIViewRoot
You obtain it via FacesContext.getCurrentInstance()
. After that - check the docs to see what can be of particular interest to you.
The FacesContext
is initialized per each request, and getCurrentInstance()
actually returns a ThreadLocal
variable.
It is to be noted, that a simple application should be able to work without the need to access the FacesContext
.
Bozho
2010-08-13 11:32:59
Thanks Bozho!!!!
vinod
2010-08-16 05:22:16
@vinod np. If an answer works for you, you can mark it as accepted (tick below the vote counter)
Bozho
2010-08-16 06:14:53