On 4/10/06, Andrew Robinson <[EMAIL PROTECTED]> wrote:
facesContext should exist as a request variable. At least with
Facelets I know this is true from others mentioning it. I'm not sure
why it wouldn't be working for you. If you are using facelets, JSP
variables will not be available (sessionScope for example).

Here is the list of variables that should be available if you are
rendering using JSP according to Sun:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html

JSF's EL supports a similar set of implicit objects -- they are implemented inside the default VariableResolver, so they act sort of like managed beans (in other words you don't have to create them).  The list of supported names is in the JSF spec (section  5.3.1.2).  Informally, start with the JSP list referenced above, remove the JSP specific things ("pageContext" and "pageScope"), and add "facesContext" (the FacesContext instance for the current request) and "view" (the root component of the current view) that are JSF specific.  So, things like "sessionScope" *are* available (if you know the bean is already there) in a JSF _expression_ as well.

Because "facesContext" is supported, you can also get access to the HttpSession or PortletSession instance with an _expression_ like this:

    #{facesContext.externalContext.session}

One of the nice things about using EL to do this is you don't have to bind your app to either the Servlet or Portlet APIs directly.  To get the session id, for example, is just a matter of evaluating:

    #{facesContext.externalContext.session.id}

Craig

Reply via email to