javax.portlet.faces
Class GenericFacesPortlet

java.lang.Object
  extended by javax.portlet.GenericPortlet
      extended by javax.portlet.faces.GenericFacesPortlet
All Implemented Interfaces:
javax.portlet.EventPortlet, javax.portlet.Portlet, javax.portlet.PortletConfig, javax.portlet.ResourceServingPortlet

public class GenericFacesPortlet
extends javax.portlet.GenericPortlet

The GenericFacesPortlet is provided to simplify development of a portlet that in whole or part relies on the Faces Bridge to process requests. If all requests are to be handled by the bridge, GenericFacesPortlet is a turnkey implementation. Developers do not need to subclass it. However, if there are some situations where the portlet doesn't require bridge services then GenericFacesPortlet can be subclassed and overriden.

Since GenericFacesPortlet subclasses GenericPortlet care is taken to all subclasses to override naturally. For example, though doDispatch() is overriden, requests are only dispatched to the bridge from here if the PortletMode isn't VIEW, EDIT, or HELP.

The GenericFacesPortlet recognizes the following portlet initialization parameters:

The GenericFacesPortlet recognizes the following application (PortletContext) initialization parameters:

Author:
Michael Freedman, Neil Griffin

Field Summary
static String BRIDGE_AUTO_DISPATCH_EVENTS
          Portlet init-param containing the setting for whether the GenericFacesPortlet overrides event processing by dispatching all events to the bridge or delegates all event processing to the GenericPortlet.
static String BRIDGE_CLASS
          Application (PortletContext) init parameter that names the bridge class used by this application.
static String BRIDGE_SERVICE_CLASSPATH
          Location of the services descriptor file in a brige installation that defines the class name of the bridge implementation.
static String DEFAULT_CHARACTERSET_ENCODING
          Deprecated. Portlet init parameter that defines the render response CharacterSetEncoding the bridge sets prior to rendering. Typcially only set when the jsp outputs an encoding other then the portlet container's and the portlet container supports response encoding transformation. It is deprecated because bridge implementations (since JSR 329) no longer utilize it.
static String DEFAULT_CONTENT_TYPE
          Deprecated. Portlet init parameter that defines the render response ContentType the bridge sets prior to rendering. If not set the bridge uses the request's preferred content type. It is deprecated because bridge implementations (since JSR 329) no longer utilize it.
static String DEFAULT_VIEWID
          Portlet init parameter that defines the default ViewId that should be used when the request doesn't otherwise convery the target.
static String INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES
          Portlet init-param that determines whether or not the init(PortletConfig) method sets PortletContext attributes from PortletConfig init-param values, such that they are namespaced with the portlet name.
 
Constructor Summary
GenericFacesPortlet()
           
 
Method Summary
 void destroy()
          Release resources, specifically it destroys the bridge.
protected  void doDispatch(javax.portlet.RenderRequest renderRequest, javax.portlet.RenderResponse renderResponse)
          If the javax.portlet.faces.automaticNonFacesViewDispatching init-param is true and the Bridge.NONFACES_TARGET_PATH_PARAMETER render request parameter specifies a value as a non-Faces target path, then forward to the non-Faces target path.
protected  void doEdit(javax.portlet.RenderRequest renderRequest, javax.portlet.RenderResponse renderResponse)
          Delegates to Bridge.doFacesRequest(RenderRequest, RenderResponse) in order to render the Faces view associated with PortletMode.EDIT.
protected  void doHeaders(javax.portlet.RenderRequest renderRequest, javax.portlet.RenderResponse renderResponse)
           
protected  void doHelp(javax.portlet.RenderRequest renderRequest, javax.portlet.RenderResponse renderResponse)
          Delegates to Bridge.doFacesRequest(RenderRequest, RenderResponse) in order to render the Faces view associated with PortletMode.HELP.
protected  void doView(javax.portlet.RenderRequest renderRequest, javax.portlet.RenderResponse renderResponse)
          Delegates to Bridge.doFacesRequest(RenderRequest, RenderResponse) in order to render the Faces view associated with PortletMode.VIEW.
 String getBridgeClassName()
          Returns the className of the bridge implementation this portlet uses.
 BridgeEventHandler getBridgeEventHandler()
          Deprecated. Call BridgeEventHandlerFactory.getBridgeEventHandler(PortletConfig) instead.

Returns an instance of a BridgeEventHandler used to process portlet events in a JSF environment. This default implementation looks for a portlet initParameter that names the class used to instantiate the handler.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

 BridgePublicRenderParameterHandler getBridgePublicRenderParameterHandler()
          Deprecated. Call BridgePublicRenderParameterHandlerFactory.getBridgePublicRenderParameterHandler(PortletConfig) instead.

Returns an instance of a BridgePublicRenderParameterHandler used to post process public render parameter changes that the bridge has pushed into mapped models. This default implementation looks for a portlet initParameter that names the class used to instantiate the handler.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

 String getDefaultRenderKitId()
          Deprecated. Call ExternalContext.getInitParameter(String) with parameter value "javax.portlet.faces.defaultRenderKitId" instead.

Returns a String defining the default render kit id the bridge should ensure for this portlet. If non-null, this value is used to override any default render kit id set on an app wide basis in the faces-config.xml. This default implementation reads the values from the portlet init-param javax.portlet.faces.defaultRenderKitId. If not present, null is returned.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

 Map<String,String> getDefaultViewIdMap()
          Deprecated. Call ExternalContext.getInitParameter(String) with parameter "javax.portlet.faces.defaultViewId.view", "javax.portlet.faces.defaultViewId.edit", or "javax.portlet.faces.defaultViewId.help", etc.

Returns a map of default viewIds that the bridge should use when it is unable to resolve to a specific target in the incoming request. There is one entry per support PortletMode. The entry key is the name of the mode. The entry value is the default viewId for that mode.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

 List<String> getExcludedRequestAttributes()
          Deprecated. Call ExternalContext.getInitParameter(String) with parameter "javax.portlet.faces.excludedRequestAttributes" instead.

Returns the set of RequestAttribute names that the portlet wants the bridge to exclude from its managed request scope. This default implementation picks up this list from the comma delimited init-param javax.portlet.faces.excludedRequestAttributes.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

 Bridge getFacesBridge(javax.portlet.PortletRequest portletRequest, javax.portlet.PortletResponse portletResponse)
          Returns an initialized bridge instance adequately prepared so the caller can call doFacesRequest directly without further initialization.
 String getResponseCharacterSetEncoding(javax.portlet.PortletRequest portletRequest)
          Deprecated. This method is no longer used or called by the GenericFacesPortlet but retained in case a subclass has called it.
 String getResponseContentType(javax.portlet.PortletRequest portletRequest)
          Deprecated. This method is no longer used or called by the GenericFacesPortlet but retained in case a subclass has called it.
 void init(javax.portlet.PortletConfig portletConfig)
          Initializes the GenericFacesPortlet according to the specified portlet configuration.
 boolean isAutoDispatchEvents()
          Returns the value of the portlet initialization parameter javax.portlet.faces.autoDispatchEvents if non-null or true, otherwise.
 boolean isPreserveActionParameters()
          Deprecated. Call ExternalContext.getInitParameter(String) with parameter "javax.portlet.faces.preserveActionParams" instead.

Returns a boolean indicating whether or not the bridge should preserve all the action parameters in the subsequent renders that occur in the same scope. This default implementation reads the values from the portlet init-param javax.portlet.faces.preserveActionParams. If not present, false is returned.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

 void processAction(javax.portlet.ActionRequest actionRequest, javax.portlet.ActionResponse actionResponse)
          Delegates to Bridge.doFacesRequest(ActionRequest, ActionResponse).
 void processEvent(javax.portlet.EventRequest eventRequest, javax.portlet.EventResponse eventResponse)
          Delegates to Bridge.doFacesRequest(EventRequest, EventResponse).
 void serveResource(javax.portlet.ResourceRequest resourceRequest, javax.portlet.ResourceResponse resourceResponse)
          Delegates to Bridge.doFacesRequest(ResourceRequest, ResourceResponse).
 
Methods inherited from class javax.portlet.GenericPortlet
getContainerRuntimeOptions, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, render
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BRIDGE_AUTO_DISPATCH_EVENTS

public static final String BRIDGE_AUTO_DISPATCH_EVENTS
Portlet init-param containing the setting for whether the GenericFacesPortlet overrides event processing by dispatching all events to the bridge or delegates all event processing to the GenericPortlet. Default is true.

See Also:
Constant Field Values

BRIDGE_CLASS

public static final String BRIDGE_CLASS
Application (PortletContext) init parameter that names the bridge class used by this application. Typically not used unless more then 1 bridge is configured in an environment as it is more usual to rely on the self detection.

See Also:
Constant Field Values

INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES

public static final String INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES
Portlet init-param that determines whether or not the init(PortletConfig) method sets PortletContext attributes from PortletConfig init-param values, such that they are namespaced with the portlet name. Default is false. Specify true in order to enable JSR 301/329 legacy behavior. See also the following deprecated methods:

See Also:
Constant Field Values

BRIDGE_SERVICE_CLASSPATH

public static final String BRIDGE_SERVICE_CLASSPATH
Location of the services descriptor file in a brige installation that defines the class name of the bridge implementation.

See Also:
Constant Field Values

DEFAULT_CONTENT_TYPE

@Deprecated
public static final String DEFAULT_CONTENT_TYPE
Deprecated. Portlet init parameter that defines the render response ContentType the bridge sets prior to rendering. If not set the bridge uses the request's preferred content type. It is deprecated because bridge implementations (since JSR 329) no longer utilize it.
See Also:
Constant Field Values

DEFAULT_CHARACTERSET_ENCODING

@Deprecated
public static final String DEFAULT_CHARACTERSET_ENCODING
Deprecated. Portlet init parameter that defines the render response CharacterSetEncoding the bridge sets prior to rendering. Typcially only set when the jsp outputs an encoding other then the portlet container's and the portlet container supports response encoding transformation. It is deprecated because bridge implementations (since JSR 329) no longer utilize it.
See Also:
Constant Field Values

DEFAULT_VIEWID

public static final String DEFAULT_VIEWID
Portlet init parameter that defines the default ViewId that should be used when the request doesn't otherwise convery the target. There must be one initialization parameter for each supported mode. Each parameter is named DEFAULT_VIEWID.mode, where mode is the name of the corresponding PortletMode

See Also:
Constant Field Values
Constructor Detail

GenericFacesPortlet

public GenericFacesPortlet()
Method Detail

destroy

public void destroy()
Release resources, specifically it destroys the bridge.

Specified by:
destroy in interface javax.portlet.Portlet
Overrides:
destroy in class javax.portlet.GenericPortlet

getBridgeClassName

public String getBridgeClassName()
Returns the className of the bridge implementation this portlet uses. Subclasses override to alter the default behavior. Default implementation first checks for a portlet context init parameter: javax.portlet.faces.BridgeImplClass. If it doesn't exist then it looks for the resource file "META-INF/services/javax.portlet.faces.Bridge" using the current threads classloader and extracts the classname from the first line in that file.

Returns:
the class name of the Bridge class the GenericFacesPortlet uses. null if it can't be determined.

getBridgeEventHandler

@Deprecated
public BridgeEventHandler getBridgeEventHandler()
                                         throws javax.portlet.PortletException
Deprecated. Call BridgeEventHandlerFactory.getBridgeEventHandler(PortletConfig) instead.

Returns an instance of a BridgeEventHandler used to process portlet events in a JSF environment. This default implementation looks for a portlet initParameter that names the class used to instantiate the handler.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

Returns:
an instance of BridgeEventHandler or null if there is none.
Throws:
javax.portlet.PortletException - - if an error occurs loading or instantiating the BridgeEventHandler class.

getBridgePublicRenderParameterHandler

@Deprecated
public BridgePublicRenderParameterHandler getBridgePublicRenderParameterHandler()
                                                                         throws javax.portlet.PortletException
Deprecated. Call BridgePublicRenderParameterHandlerFactory.getBridgePublicRenderParameterHandler(PortletConfig) instead.

Returns an instance of a BridgePublicRenderParameterHandler used to post process public render parameter changes that the bridge has pushed into mapped models. This default implementation looks for a portlet initParameter that names the class used to instantiate the handler.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

Returns:
an instance of BridgeRenderParameterHandler or null if there is none.
Throws:
javax.portlet.PortletException - - if an error occurs loading or instantiating the BridgePublicRenderParameterHandler class.

getDefaultRenderKitId

@Deprecated
public String getDefaultRenderKitId()
Deprecated. Call ExternalContext.getInitParameter(String) with parameter value "javax.portlet.faces.defaultRenderKitId" instead.

Returns a String defining the default render kit id the bridge should ensure for this portlet. If non-null, this value is used to override any default render kit id set on an app wide basis in the faces-config.xml. This default implementation reads the values from the portlet init-param javax.portlet.faces.defaultRenderKitId. If not present, null is returned.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

Returns:
a boolean indicating whether or not the bridge should preserve all the action parameters in the subsequent renders that occur in the same scope.

getDefaultViewIdMap

@Deprecated
public Map<String,String> getDefaultViewIdMap()
Deprecated. Call ExternalContext.getInitParameter(String) with parameter "javax.portlet.faces.defaultViewId.view", "javax.portlet.faces.defaultViewId.edit", or "javax.portlet.faces.defaultViewId.help", etc.

Returns a map of default viewIds that the bridge should use when it is unable to resolve to a specific target in the incoming request. There is one entry per support PortletMode. The entry key is the name of the mode. The entry value is the default viewId for that mode.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

Returns:
the map of default viewIds.

getExcludedRequestAttributes

@Deprecated
public List<String> getExcludedRequestAttributes()
Deprecated. Call ExternalContext.getInitParameter(String) with parameter "javax.portlet.faces.excludedRequestAttributes" instead.

Returns the set of RequestAttribute names that the portlet wants the bridge to exclude from its managed request scope. This default implementation picks up this list from the comma delimited init-param javax.portlet.faces.excludedRequestAttributes.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

Returns:
a List containing the names of the attributes to be excluded. null if it can't be determined.

getFacesBridge

public Bridge getFacesBridge(javax.portlet.PortletRequest portletRequest,
                             javax.portlet.PortletResponse portletResponse)
                      throws javax.portlet.PortletException
Returns an initialized bridge instance adequately prepared so the caller can call doFacesRequest directly without further initialization.

Parameters:
portletRequest - The current portlet request.
portletResponse - The current portlet response.
Returns:
An instance of the bridge.
Throws:
javax.portlet.PortletException - - if an error occurs acquiring or initializing the bridge.

getResponseCharacterSetEncoding

@Deprecated
public String getResponseCharacterSetEncoding(javax.portlet.PortletRequest portletRequest)
Deprecated. This method is no longer used or called by the GenericFacesPortlet but retained in case a subclass has called it.

Parameters:
portletRequest - The current portlet request.
Returns:
null

getResponseContentType

@Deprecated
public String getResponseContentType(javax.portlet.PortletRequest portletRequest)
Deprecated. This method is no longer used or called by the GenericFacesPortlet but retained in case a subclass has called it.

Parameters:
portletRequest - The current portlet request.
Returns:
The value obtained by calling PortletRequest.getResponseContentType().

init

public void init(javax.portlet.PortletConfig portletConfig)
          throws javax.portlet.PortletException
Initializes the GenericFacesPortlet according to the specified portlet configuration.

Specified by:
init in interface javax.portlet.Portlet
Overrides:
init in class javax.portlet.GenericPortlet
Parameters:
portletConfig - The portlet configuration.
Throws:
javax.portlet.PortletException - - if an error occurs acquiring or initializing the bridge.

isAutoDispatchEvents

public boolean isAutoDispatchEvents()
Returns the value of the portlet initialization parameter javax.portlet.faces.autoDispatchEvents if non-null or true, otherwise.

Returns:
boolean indicating whether to auto-dispatch all events to the bridge or not.

isPreserveActionParameters

@Deprecated
public boolean isPreserveActionParameters()
Deprecated. Call ExternalContext.getInitParameter(String) with parameter "javax.portlet.faces.preserveActionParams" instead.

Returns a boolean indicating whether or not the bridge should preserve all the action parameters in the subsequent renders that occur in the same scope. This default implementation reads the values from the portlet init-param javax.portlet.faces.preserveActionParams. If not present, false is returned.

Note that this method will only be called by init(PortletConfig) if the INITIALIZE_NAMESPACED_CONTEXT_ATTRIBUTES init-param is true in WEB-INF/portlet.xml.

Returns:
a boolean indicating whether or not the bridge should preserve all the action parameters in the subsequent renders that occur in the same scope.

processAction

public void processAction(javax.portlet.ActionRequest actionRequest,
                          javax.portlet.ActionResponse actionResponse)
                   throws javax.portlet.PortletException,
                          IOException
Delegates to Bridge.doFacesRequest(ActionRequest, ActionResponse).

Specified by:
processAction in interface javax.portlet.Portlet
Overrides:
processAction in class javax.portlet.GenericPortlet
Parameters:
actionRequest - The current action request.
actionResponse - The current action response.
Throws:
javax.portlet.PortletException - - if an error occurs during action request/response processing.
IOException - - if an error occurs during action response processing such as a call to ActionResponse.sendRedirect(String).

processEvent

public void processEvent(javax.portlet.EventRequest eventRequest,
                         javax.portlet.EventResponse eventResponse)
                  throws javax.portlet.PortletException,
                         IOException
Delegates to Bridge.doFacesRequest(EventRequest, EventResponse).

Specified by:
processEvent in interface javax.portlet.EventPortlet
Overrides:
processEvent in class javax.portlet.GenericPortlet
Parameters:
eventRequest - The current event request.
eventResponse - The current event response.
Throws:
javax.portlet.PortletException - - if an error occurs during event request/response processing.
IOException - - if an error occurs during event response processing.

serveResource

public void serveResource(javax.portlet.ResourceRequest resourceRequest,
                          javax.portlet.ResourceResponse resourceResponse)
                   throws javax.portlet.PortletException,
                          IOException
Delegates to Bridge.doFacesRequest(ResourceRequest, ResourceResponse).

Specified by:
serveResource in interface javax.portlet.ResourceServingPortlet
Overrides:
serveResource in class javax.portlet.GenericPortlet
Parameters:
resourceRequest - The current resource request.
resourceResponse - The current resource response.
Throws:
javax.portlet.PortletException - - if an error occurs during resource request/response processing.
IOException - - if an error occurs while writing to the resource response.

doDispatch

protected void doDispatch(javax.portlet.RenderRequest renderRequest,
                          javax.portlet.RenderResponse renderResponse)
                   throws javax.portlet.PortletException,
                          IOException
If the javax.portlet.faces.automaticNonFacesViewDispatching init-param is true and the Bridge.NONFACES_TARGET_PATH_PARAMETER render request parameter specifies a value as a non-Faces target path, then forward to the non-Faces target path. Otherwise, delegates to the GenericPortlet.doDispatch(RenderRequest, RenderResponse) method so that the doView(RenderRequest, RenderResponse), doEdit(RenderRequest, RenderResponse), or doHelp(RenderRequest, RenderResponse) methods will handle the dispatching.

Overrides:
doDispatch in class javax.portlet.GenericPortlet
Parameters:
renderRequest - The current render request.
renderResponse - The current render response.
Throws:
javax.portlet.PortletException - - if an error occurs during render request/response processing.
IOException - - if an error occurs while writing to the render response.

doEdit

protected void doEdit(javax.portlet.RenderRequest renderRequest,
                      javax.portlet.RenderResponse renderResponse)
               throws javax.portlet.PortletException,
                      IOException
Delegates to Bridge.doFacesRequest(RenderRequest, RenderResponse) in order to render the Faces view associated with PortletMode.EDIT.

Overrides:
doEdit in class javax.portlet.GenericPortlet
Parameters:
renderRequest - The current render request.
renderResponse - The current render response.
Throws:
javax.portlet.PortletException - - if an error occurs during render request/response processing.
IOException - - if an error occurs while writing to the render response.

doHeaders

protected void doHeaders(javax.portlet.RenderRequest renderRequest,
                         javax.portlet.RenderResponse renderResponse)
Overrides:
doHeaders in class javax.portlet.GenericPortlet

doHelp

protected void doHelp(javax.portlet.RenderRequest renderRequest,
                      javax.portlet.RenderResponse renderResponse)
               throws javax.portlet.PortletException,
                      IOException
Delegates to Bridge.doFacesRequest(RenderRequest, RenderResponse) in order to render the Faces view associated with PortletMode.HELP.

Overrides:
doHelp in class javax.portlet.GenericPortlet
Parameters:
renderRequest - The current render request.
renderResponse - The current render response.
Throws:
javax.portlet.PortletException - - if an error occurs during render request/response processing.
IOException - - if an error occurs while writing to the render response.

doView

protected void doView(javax.portlet.RenderRequest renderRequest,
                      javax.portlet.RenderResponse renderResponse)
               throws javax.portlet.PortletException,
                      IOException
Delegates to Bridge.doFacesRequest(RenderRequest, RenderResponse) in order to render the Faces view associated with PortletMode.VIEW.

Overrides:
doView in class javax.portlet.GenericPortlet
Parameters:
renderRequest - The current render request.
renderResponse - The current resource request.
Throws:
javax.portlet.PortletException - - if an error occurs during render request/response processing.
IOException - - if an error occurs while writing to the render response.


Copyright © 2017 Liferay, Inc. All Rights Reserved.