By: Henry Emailed: 1768 times Printed: 2515 times
JSF provides access to the request data and other data through the FacesContext object. As the Javadoc states, “FacesContext contains all of the per-request state information related to the processing of a single JavaServer Faces request, and the rendering of the corresponding response . . . . A FacesContext instance is associated with a particular request at the beginning of request processing.” Because a FacesContext instance, and the objects it contains, are associated with the thread processing a particular request, any references to the FacesContext instance or its contained objects must not be passed to another thread or stored for subsequent requests.
You can access the FacesContext object like this:
FacesContext context = FacesContext.getCurrentInstance();
After you have a reference to the FacesContext for the request, you can access all the request and application data through the ExternalContext object. The reference to the ExternalContext object is obtained through the call to the getExternalContext() method. Table below shows the methods of ExternalContext that return collections of request and application data. You can use these methods to access request data, session data, request header data, cookie data, and other sets of data in the application.
Most likely, if you are accessing request or application data in a managed bean, you will be accessing request data or session data. As you can see in Table, you access request data through the getRequestParameterMap() or getRequestParameterValuesMap() method. You can access session data through the getSessionMap() method.
View Tutorial By: Fred at 2009-03-11 08:42:59
Most Viewed Articles (in JSF )
Most Emailed Articles (in JSF)