javax.portlet.faces
Class GenericFacesPortlet

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

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 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
          Portlet init parameter that defines the render response CharacterSetEncoding the bridge sets prior to rendering.
static String DEFAULT_CONTENT_TYPE
          Portlet init parameter that defines the render response ContentType the bridge sets prior to rendering.
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.
 
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)
           
 String getBridgeClassName()
          Returns the className of the bridge implementation this portlet uses.
 Map getDefaultViewIdMap()
          Returns the defaultViewIdMap the bridge should use when its unable to resolve to a specific target in the incoming request.
 List<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.
 String getResponseCharacterSetEncoding(PortletRequest request)
          Returns the character set encoding used for this portlet response.
 String getResponseContentType(PortletRequest request)
          Returns the default content type for this portlet request.
 void init(PortletConfig portletConfig)
          Initialize generic faces portlet from portlet.xml
 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)
           
 
Methods inherited from class javax.portlet.GenericPortlet
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

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 its more usual to rely on the self detection.

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

DEFAULT_CONTENT_TYPE

public static final 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 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_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
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,
                       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
IOException

doEdit

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

doHelp

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

doView

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

processAction

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

getExcludedRequestAttributes

public List<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.

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.

getResponseContentType

public String getResponseContentType(PortletRequest request)
Returns the default content type for this portlet request. Subclasses override to alter the default behavior. Default implementation returns value of the portlet init parameter: javax.portlet.faces.DefaultContentType. If it doesn't exist or the value isn't in the lisst of requested types, the portlet request's preferred response content type is returned. Note: This support is specific to the Portlet 1.0 Bridge. Its value is likely to be ignored by the Portlet 2.0 Bridge or later.

Returns:
the content type that should be used for this response.

getResponseCharacterSetEncoding

public String getResponseCharacterSetEncoding(PortletRequest request)
Returns the character set encoding used for this portlet response. Subclasses override to alter the default behavior. Default implementation returns value of the portlet init parameter: javax.portlet.faces.DefaultCharacterSetEncoding. If it doesn't exist null is returned. Note: This support is specific to the Portlet 1.0 Bridge. Its value is likely to be ignored by the Portlet 2.0 Bridge or later.

Returns:
the content type that should be used for this response.

getDefaultViewIdMap

public 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

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.


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