## org.apache.portals.bridges.jsf
Class FacesPortlet

    java.lang.Object
      javax.portlet.GenericPortlet
          org.apache.portals.bridges.common.GenericServletPortlet
              org.apache.portals.bridges.jsf.FacesPortlet

All Implemented Interfaces:
  javax.portlet.Portlet, javax.portlet.PortletConfig

public class FacesPortlet
extends org.apache.portals.bridges.common.GenericServletPortlet

FacesPortlet utilizes Java Server Faces to create the user interface in a portlet environment.

Author:
  David Le Strat, David Sean Taylor

Field Summary
`static String` `ACTION_REQUEST` Action request.
`private javax.faces.application.Application` `application` The `Application`instance for this web application.
`static String` `CUSTOM_REQUEST` Custom request.
`private String` `defaultActionPage` Default URL for the action page.
`private String` `defaultCustomPage` Default URL for the custom page.
`private String` `defaultEditPage` Default URL for the edit page.
`private String` `defaultHelpPage` Default URL for the help page.
`private String` `defaultViewPage` Default URL for the view page.
`static String` `EDIT_REQUEST` Edit request.
`static String` `FACES_MESSAGES` FacesMessage objects on portlet session
`private javax.faces.context.FacesContextFactory` `facesContextFactory` Factory for `FacesContext`instances.
`static String` `HELP_REQUEST` Help request.
`static String` `JSF_CUSTOM_ID`
`static String` `JSF_EDIT_ID`
`static String` `JSF_HELP_ID`
`static String` `JSF_VIEW_ID` The JSF_VIEW_ID used to maintain the state of the view action.
`private javax.faces.lifecycle.Lifecycle` `lifecycle` The `Lifecycle`instance to use for request processing.
`private static String` `LIFECYCLE_ID_ATTR` Context initialization parameter name for the lifecycle identifier of the `Lifecycle`instance to be utilized.
`private static org.apache.commons.logging.Log` `log` The Log instance for this class.
`static String` `PARAM_ACTION_PAGE` Name of portlet preference for Action page.
`static String` `PARAM_CUSTOM_PAGE` Name of portlet preference for Custom page.
`static String` `PARAM_EDIT_PAGE` Name of portlet preference for Edit page.
`static String` `PARAM_HELP_PAGE` Name of portlet preference for Edit page
`static String` `PARAM_UNIQUE_IDS` Override default behavior for Unique IDS
`static String` `PARAM_VIEW_PAGE` Name of portlet preference for View page
`private javax.portlet.PortletConfig` `portletConfig` The `PortletConfig` instance for this portlet.
`static String` `REQUEST_SERVLET_PATH` The REQUEST_SERVLET_PATH used for externalContext.getRequestServletPath().
`static String` `REQUEST_TYPE` The REQUEST_TYPE request attribute can be used to determine the Portlet request type (`ACTION_REQUEST`, `VIEW_REQUEST`, `HELP_REQUEST`, `EDIT_REQUEST` or `CUSTOM_REQUEST`) of the current request.
`private String` `uniqueIds`
`static String` `VIEW_REQUEST` View request.
`static String` `VIEW_ROOT` The VIEW_ROOT used to keep track of action between the action request and the render request.

Fields inherited from class org.apache.portals.bridges.common.GenericServletPortlet
`PARAM_ALLOW_PREFERENCES, PARAM_MAX_PAGE`

Fields inherited from class javax.portlet.GenericPortlet
``

Constructor Summary
`FacesPortlet()`

Method Summary
`protected void` `cleanUpAfterPortal(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response)` Removes temporary JSF attributes from the request.
`private String` `createViewRootKey(javax.faces.context.FacesContext context, String defaultView, String viewId)`
`void` `destroy()` Release all resources acquired at startup time.
`void` `doCustom(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)`
`void` `doEdit(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)`
`void` `doHelp(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)`
`void` `doView(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)`
`javax.faces.context.FacesContextFactory` `getFacesContextFactory()` Gets the `FacesContextFactory`.
`javax.faces.lifecycle.Lifecycle` `getLifecycle()` Get the faces life cycle.
`void` `init(javax.portlet.PortletConfig portletConfig)` Acquire the factory instance we will require.
`protected void` `preProcessFaces(javax.faces.context.FacesContext context)`
`private void` `process(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response, String defaultPage, String requestType, String viewId)` Processes the request.
`void` `processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)`
`private void` `restoreFacesMessages(javax.faces.context.FacesContext context, javax.portlet.PortletSession session)` Restore FacesMessage objects from the PortletSession
`private void` `saveFacesMessages(javax.faces.context.FacesContext context, javax.portlet.PortletSession session)` Save FacesMessage objects on the PortletSession
`private void` `setDefaultView(javax.faces.context.FacesContext facesContext, String defaultView, String viewId)` Set the view identifier to the view for the page to be rendered.

Methods inherited from class org.apache.portals.bridges.common.GenericServletPortlet
`getDefaultActionPage, getDefaultCustomPage, getDefaultEditPage, getDefaultHelpPage, getDefaultViewPage, processPreferencesAction, setDefaultActionPage, setDefaultCustomPage, setDefaultEditPage, setDefaultHelpPage, setDefaultViewPage`

Methods inherited from class javax.portlet.GenericPortlet
`doDispatch, getInitParameter, getInitParameterNames, getPortletConfig, getPortletContext, getPortletName, getResourceBundle, getTitle, init, render`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    private static final org.apache.commons.logging.Log log

  The Log instance for this class.

### VIEW_ROOT

    public static final String VIEW_ROOT

  The VIEW_ROOT used to keep track of action between the action request and the render request.

  See Also:
    Constant Field Values

### REQUEST_SERVLET_PATH

    public static final String REQUEST_SERVLET_PATH

  The REQUEST_SERVLET_PATH used for externalContext.getRequestServletPath(). externalContext.getRequestServletPath() should return null but this is a work around an issue with MyFaces JspViewHandler implementation getServletMapping().

  See Also:
    Constant Field Values

### REQUEST_TYPE

    public static final String REQUEST_TYPE

  The REQUEST_TYPE request attribute can be used to determine the Portlet request type (`ACTION_REQUEST`, `VIEW_REQUEST`, `HELP_REQUEST`, `EDIT_REQUEST` or `CUSTOM_REQUEST`) of the current request.

  See Also:
    Constant Field Values

### JSF_VIEW_ID

    public static final String JSF_VIEW_ID

  The JSF_VIEW_ID used to maintain the state of the view action.

  See Also:
    Constant Field Values

### JSF_EDIT_ID

    public static final String JSF_EDIT_ID

See Also:
  Constant Field Values

### JSF_HELP_ID

    public static final String JSF_HELP_ID

See Also:
  Constant Field Values

### JSF_CUSTOM_ID

    public static final String JSF_CUSTOM_ID

See Also:
  Constant Field Values

### PARAM_ACTION_PAGE

    public static final String PARAM_ACTION_PAGE

  Name of portlet preference for Action page.

  See Also:
    Constant Field Values

### PARAM_CUSTOM_PAGE

    public static final String PARAM_CUSTOM_PAGE

  Name of portlet preference for Custom page.

  See Also:
    Constant Field Values

### PARAM_EDIT_PAGE

    public static final String PARAM_EDIT_PAGE

  Name of portlet preference for Edit page.

  See Also:
    Constant Field Values

### PARAM_HELP_PAGE

    public static final String PARAM_HELP_PAGE

  Name of portlet preference for Edit page

  See Also:
    Constant Field Values

### PARAM_VIEW_PAGE

    public static final String PARAM_VIEW_PAGE

  Name of portlet preference for View page

  See Also:
    Constant Field Values

### ACTION_REQUEST

    public static final String ACTION_REQUEST

  Action request.

  See Also:
    Constant Field Values

### VIEW_REQUEST

    public static final String VIEW_REQUEST

  View request.

  See Also:
    Constant Field Values

### CUSTOM_REQUEST

    public static final String CUSTOM_REQUEST

  Custom request.

  See Also:
    Constant Field Values

### EDIT_REQUEST

    public static final String EDIT_REQUEST

  Edit request.

  See Also:
    Constant Field Values

### HELP_REQUEST

    public static final String HELP_REQUEST

  Help request.

  See Also:
    Constant Field Values

### FACES_MESSAGES

    public static final String FACES_MESSAGES

  FacesMessage objects on portlet session

  See Also:
    Constant Field Values

### PARAM_UNIQUE_IDS

    public static final String PARAM_UNIQUE_IDS

  Override default behavior for Unique IDS

  See Also:
    Constant Field Values

### defaultActionPage

    private String defaultActionPage

  Default URL for the action page.

### defaultCustomPage

    private String defaultCustomPage

  Default URL for the custom page.

### defaultEditPage

    private String defaultEditPage

  Default URL for the edit page.

### defaultHelpPage

    private String defaultHelpPage

  Default URL for the help page.

### defaultViewPage

    private String defaultViewPage

  Default URL for the view page.

### uniqueIds

    private String uniqueIds

### LIFECYCLE_ID_ATTR

    private static final String LIFECYCLE_ID_ATTR

  Context initialization parameter name for the lifecycle identifier of the `Lifecycle`instance to be utilized.

  See Also:
    Constant Field Values

### application

    private javax.faces.application.Application application

  The `Application`instance for this web application.

### facesContextFactory

    private javax.faces.context.FacesContextFactory facesContextFactory

  Factory for `FacesContext`instances.

### lifecycle

    private javax.faces.lifecycle.Lifecycle lifecycle

  The `Lifecycle`instance to use for request processing.

### portletConfig

    private javax.portlet.PortletConfig portletConfig

  The `PortletConfig` instance for this portlet.

Constructor Detail

### FacesPortlet

    public FacesPortlet()

Method Detail

### destroy

    public void destroy()

  Release all resources acquired at startup time.

### init

    public void init(javax.portlet.PortletConfig portletConfig)
              throws javax.portlet.PortletException

  Acquire the factory instance we will require.

  Throws:
    `javax.portlet.PortletException` - if, for any reason, the startp of this Faces application failed. This includes errors in the config file that is parsed before or during the processing of this `init()` method.

### doEdit

    public void doEdit(javax.portlet.RenderRequest request,
                       javax.portlet.RenderResponse response)
                throws javax.portlet.PortletException,
                       IOException

  Throws:
    `javax.portlet.PortletException`
    `IOException`
  See Also:
    `GenericPortlet.doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)`

### doHelp

    public void doHelp(javax.portlet.RenderRequest request,
                       javax.portlet.RenderResponse response)
                throws javax.portlet.PortletException,
                       IOException

  Throws:
    `javax.portlet.PortletException`
    `IOException`
  See Also:
    `GenericPortlet.doHelp(javax.portlet.RenderRequest, javax.portlet.RenderResponse)`

### doCustom

    public void doCustom(javax.portlet.RenderRequest request,
                         javax.portlet.RenderResponse response)
                  throws javax.portlet.PortletException,
                         IOException

  Parameters:
    `request` - The `RenderRequest`.
    `response` - The `RenderResponse`.
  Throws:
    `javax.portlet.PortletException` - Throws a `PortletException`.
    `IOException` - Throws a `IOException`.

### doView

    public void doView(javax.portlet.RenderRequest request,
                       javax.portlet.RenderResponse response)
                throws javax.portlet.PortletException,
                       IOException

  Throws:
    `javax.portlet.PortletException`
    `IOException`
  See Also:
    `GenericPortlet.doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)`

### processAction

    public void processAction(javax.portlet.ActionRequest request,
                              javax.portlet.ActionResponse response)
                       throws javax.portlet.PortletException,
                              IOException

  Throws:
    `javax.portlet.PortletException`
    `IOException`
  See Also:
    `Portlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)`

### getFacesContextFactory

    public javax.faces.context.FacesContextFactory getFacesContextFactory()
                                                                   throws javax.portlet.PortletException

  Gets the `FacesContextFactory`.

  Returns:
    The `FacesContextFactory`.
  Throws:
    `javax.portlet.PortletException` - Throws a `PortletException`.

### getLifecycle

    public javax.faces.lifecycle.Lifecycle getLifecycle()
                                                 throws javax.portlet.PortletException

  Get the faces life cycle.

  Returns:
    The `Lifecycle`.
  Throws:
    `javax.portlet.PortletException` - Throws a `PortletException`.

### process

    private void process(javax.portlet.PortletRequest request,
                         javax.portlet.PortletResponse response,
                         String defaultPage,
                         String requestType,
                         String viewId)
                  throws javax.portlet.PortletException,
                         IOException

  Processes the request.

  Parameters:
    `request` - The `PortletRequest`.
    `response` - The `PortletResponse`.
    `defaultPage` - The default page.
    `requestType` - The request type.
  Throws:
    `javax.portlet.PortletException` - Throws a `PortletException`.
    `IOException` - Throws an `IOException`.

### preProcessFaces

    protected void preProcessFaces(javax.faces.context.FacesContext context)

### createViewRootKey

    private String createViewRootKey(javax.faces.context.FacesContext context,
                                     String defaultView,
                                     String viewId)

### setDefaultView

    private void setDefaultView(javax.faces.context.FacesContext facesContext,
                                String defaultView,
                                String viewId)

  Set the view identifier to the view for the page to be rendered.

  Parameters:
    `defaultView` - The default view identifier.
  Returns:
    The default view.

### saveFacesMessages

    private void saveFacesMessages(javax.faces.context.FacesContext context,
                                   javax.portlet.PortletSession session)

  Save FacesMessage objects on the PortletSession

  Parameters:
    `context` -
    `session` -

### restoreFacesMessages

    private void restoreFacesMessages(javax.faces.context.FacesContext context,
                                      javax.portlet.PortletSession session)

  Restore FacesMessage objects from the PortletSession

  Parameters:
    `context` -
    `session` -

### cleanUpAfterPortal

    protected void cleanUpAfterPortal(javax.portlet.PortletRequest request,
                                      javax.portlet.PortletResponse response)

  Removes temporary JSF attributes from the request. Under certain circumstances, internal JSF attributes from one portlet become available to another portlet on the same page (this can happen, for example, when first portlet throws an exception while rendering). If this happens, a portlet would not render correctly. Theoretically, Portlet server should make sure that no request attributes from one portlet are visible to another portlet. In practice this isn't always the case, so a portlet needs to remove those request attributes before doing anything else.

  Parameters:
    `request` - portlet request we are processing
    `response` - portlet response we are processing

Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.