javax.portlet.faces
Class GenericFacesPortlet

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

public class GenericFacesPortlet
extends 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:


Field Summary
static java.lang.String BRIDGE_AUTO_DISPATCH_EVENTS
          Portlet init parameter 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 java.lang.String BRIDGE_CLASS
          Application (PortletContext) init parameter that names the bridge class used by this application.
static java.lang.String BRIDGE_SERVICE_CLASSPATH
          Location of the services descriptor file in a brige installation that defines the class name of the bridge implementation.
static java.lang.String DEFAULT_CHARACTERSET_ENCODING
          Portlet init parameter that defines the render response CharacterSetEncoding the bridge sets prior to rendering.
static java.lang.String DEFAULT_CONTENT_TYPE
          Portlet init parameter that defines the render response ContentType the bridge sets prior to rendering.
static java.lang.String DEFAULT_VIEWID
          Portlet init parameter that defines the default ViewId that should be used when the request doesn't otherwise convery the target.
 
Constructor Summary
GenericFacesPortlet()
           
 
Method Summary
 void destroy()
          Release resources, specifically it destroys the bridge.
 void doDispatch(RenderRequest request, RenderResponse response)
          If mode is VIEW, EDIT, or HELP -- defer to the doView, doEdit, doHelp so subclasses can override.
protected  void doEdit(RenderRequest request, RenderResponse response)
           
protected  void doHelp(RenderRequest request, RenderResponse response)
           
protected  void doView(RenderRequest request, RenderResponse response)
           
 java.lang.String getBridgeClassName()
          Returns the className of the bridge implementation this portlet uses.
 BridgeEventHandler getBridgeEventHandler()
          Returns an instance of a BridgeEventHandler used to process portlet events in a JSF environment.
 BridgePublicRenderParameterHandler getBridgePublicRenderParameterHandler()
          Returns an instance of a BridgePublicRenderParameterHandler used to post process public render parameter changes that the bridge has pushed into mapped models.
 java.lang.String getDefaultRenderKitId()
          Returns a String defining the default render kit id the bridge should ensure for this portlet.
 java.util.Map getDefaultViewIdMap()
          Returns the defaultViewIdMap the bridge should use when its unable to resolve to a specific target in the incoming request.
 java.util.List<java.lang.String> getExcludedRequestAttributes()
          Returns the set of RequestAttribute names that the portlet wants the bridge to exclude from its managed request scope.
 Bridge getFacesBridge(PortletRequest request, PortletResponse response)
          Returns an initialized bridge instance adequately prepared so the caller can call doFacesRequest directly without further initialization.
 java.lang.String getResponseCharacterSetEncoding(PortletRequest request)
          Deprecated. -- no longer used or called by the GenericFacesPortlet but retained in case a subclass has called it.
 java.lang.String getResponseContentType(PortletRequest request)
          Deprecated. -- no longer used or called by the GenericFacesPortlet but retained in case a subclass has called it.
 void init(PortletConfig portletConfig)
          Initialize generic faces portlet from portlet.xml
 boolean isAutoDispatchEvents()
          Returns the value of the portlet initialization parameter javax.portlet.faces.autoDispatchEvents if non-null or true, otherwise.
 boolean isPreserveActionParameters()
          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.
 void processAction(ActionRequest request, ActionResponse response)
           
 void processEvent(EventRequest request, EventResponse response)
           
 void serveResource(ResourceRequest request, ResourceResponse response)
          Handles resource requests and dispatches to the Bridge
 
Methods inherited from class javax.portlet.GenericPortlet
doHeaders, 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_CLASS

public static final java.lang.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 its more usual to rely on the self detection.

See Also:
Constant Field Values

DEFAULT_VIEWID

public static final java.lang.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

DEFAULT_CONTENT_TYPE

public static final java.lang.String DEFAULT_CONTENT_TYPE
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.

See Also:
Constant Field Values

DEFAULT_CHARACTERSET_ENCODING

public static final java.lang.String DEFAULT_CHARACTERSET_ENCODING
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.

See Also:
Constant Field Values

BRIDGE_AUTO_DISPATCH_EVENTS

public static final java.lang.String BRIDGE_AUTO_DISPATCH_EVENTS
Portlet init parameter 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_SERVICE_CLASSPATH

public static final java.lang.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
Constructor Detail

GenericFacesPortlet

public GenericFacesPortlet()
Method Detail

init

public void init(PortletConfig portletConfig)
          throws PortletException
Initialize generic faces portlet from portlet.xml

Specified by:
init in interface Portlet
Overrides:
init in class GenericPortlet
Throws:
PortletException

destroy

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

Specified by:
destroy in interface Portlet
Overrides:
destroy in class GenericPortlet

doDispatch

public void doDispatch(RenderRequest request,
                       RenderResponse response)
                throws PortletException,
                       java.io.IOException
If mode is VIEW, EDIT, or HELP -- defer to the doView, doEdit, doHelp so subclasses can override. Otherwise handle mode here if there is a defaultViewId mapping for it.

Overrides:
doDispatch in class GenericPortlet
Throws:
PortletException
java.io.IOException

doEdit

protected void doEdit(RenderRequest request,
                      RenderResponse response)
               throws PortletException,
                      java.io.IOException
Overrides:
doEdit in class GenericPortlet
Throws:
PortletException
java.io.IOException

doHelp

protected void doHelp(RenderRequest request,
                      RenderResponse response)
               throws PortletException,
                      java.io.IOException
Overrides:
doHelp in class GenericPortlet
Throws:
PortletException
java.io.IOException

doView

protected void doView(RenderRequest request,
                      RenderResponse response)
               throws PortletException,
                      java.io.IOException
Overrides:
doView in class GenericPortlet
Throws:
PortletException
java.io.IOException

processAction

public void processAction(ActionRequest request,
                          ActionResponse response)
                   throws PortletException,
                          java.io.IOException
Specified by:
processAction in interface Portlet
Overrides:
processAction in class GenericPortlet
Throws:
PortletException
java.io.IOException

serveResource

public void serveResource(ResourceRequest request,
                          ResourceResponse response)
                   throws PortletException,
                          java.io.IOException
Handles resource requests and dispatches to the Bridge

Specified by:
serveResource in interface ResourceServingPortlet
Overrides:
serveResource in class GenericPortlet
Throws:
PortletException
java.io.IOException

getBridgeEventHandler

public BridgeEventHandler getBridgeEventHandler()
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.

Returns:
an instance of BridgeEventHandler or null if there is none.

getBridgePublicRenderParameterHandler

public BridgePublicRenderParameterHandler getBridgePublicRenderParameterHandler()
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.

Returns:
an instance of BridgeRenderParameterHandler or null if there is none.

getExcludedRequestAttributes

public java.util.List<java.lang.String> getExcludedRequestAttributes()
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.

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

isPreserveActionParameters

public boolean isPreserveActionParameters()
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.

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.

getDefaultRenderKitId

public java.lang.String getDefaultRenderKitId()
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.

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.

getBridgeClassName

public java.lang.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.

getResponseContentType

@Deprecated
public java.lang.String getResponseContentType(PortletRequest request)
Deprecated. -- no longer used or called by the GenericFacesPortlet but retained in case a subclass has called it.

Returns:
request.getResponseContentType().

getResponseCharacterSetEncoding

@Deprecated
public java.lang.String getResponseCharacterSetEncoding(PortletRequest request)
Deprecated. -- no longer used or called by the GenericFacesPortlet but retained in case a subclass has called it.

Returns:
null.

getDefaultViewIdMap

public java.util.Map getDefaultViewIdMap()
Returns the defaultViewIdMap the bridge should use when its 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.

Returns:
the defaultViewIdMap

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.

getFacesBridge

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

Returns:
instance of the bridge.
Throws:
PortletException - exception acquiring or initializting the bridge.

processEvent

public void processEvent(EventRequest request,
                         EventResponse response)
                  throws PortletException,
                         java.io.IOException
Specified by:
processEvent in interface EventPortlet
Overrides:
processEvent in class GenericPortlet
Throws:
PortletException
java.io.IOException


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.