The
Java Server Faces (JSF 1.1) framework uses a FacesContext object to store all the contextual information related to a single incoming request from a client , and all the information needed to create a response to send back to the client. Stored messages, beans, renderKits and responseWriters are all examples of this form of information, which can then be used by the JSF framework to manage an XPages UI component's state for the duration of the request processing life-cycle.
External Context:
One of the more important pieces of information stored in the FacesContext is the ExternalContext which is a wrapper that provides access to the web container context and it is transparent to how the underlying server is implemented, i.e. servlet or a portlet. The ExternalContext can be used to access information about the request, such as the request header, cookies, locale, request parameters, session information, file and resource paths, and the application environment context. The application environment context can further be used to find information about the servlet or portlet running the application.
Each of the methods published in
the APIs for FacesContext and ExternalContext can be accessed by the global JavaScript objects made available to XPages developers. For example, add the following lines of code your JavaScript to access the request object and information about the request using the facesContext global object:
var externalContext = facesContext.getExternalContext();
var request = externalContext.getRequest(); this is a HttpServletRequest
var serverName = request.getServerName();
var cookie = request.getHeader("Cookie");
Further examples:
Examples of how to use the facesContext global object can also be found by opening the
xpCGIVariables server-side JavaScript library in the discussion8.ntf template:
In Domino Designer, select
File ->
Application ->
Open ->
server name ->
discussion8.ntf.
In the navigator window, expand the following menu elements:
Code ->
Script Libraries and open the library xpCGIVariables.
For further details of how to use the JavaScript global objects see the articles on "Global Objects" and "JavaScript libraries in the XPages engine"