GenericPortlet class provides a default implementation for
the Portlet interface.
It provides an abstract class to be subclassed to create portlets. A subclass
of GenericPortlet should either use one of the following annotations:
@ProcessAction@ProcessEvent@RenderModeNormally there is no need to override the render or the doDispatch methods. Render handles render requests setting the title of the portlet in the response and invoking doDispatch. doDispatch dispatches the request to one of the doView, doEdit or doHelp method depending on the portlet mode indicated in the request.
Portlets typically run on multithreaded servers, so please note that a portlet must handle concurrent requests and be careful to synchronize access to shared resources. Shared resources include in-memory data such as instance or class variables and external objects such as files, database connections, and network connections.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | AUTOMATIC_RESOURCE_DISPATCH
This property is set by the container if the container
has a cached response for the given validation tag.
|
| private transient PortletConfig | |
| private transient Map | |
| private transient Map | |
| private transient Map |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| public void | destroy()
Implements javax. |
| protected boolean | Returns: true, if the request was dispatched,
false, if no annotated method matching the specified action
method name could be found.Annotation name name, ActionRequest Action request request, ActionResponse Action response response)
Dispatches an action request to an annotated action method.
|
| protected boolean | Returns: true, if the request was dispatched,
false, if no annotated method matching the specified event
method name could be found.Annotation name name, EventRequest Event request request, EventResponse Event response response)
Dispatches an event request to an annotated event method.
|
| protected boolean | Returns: true, if the request was dispatched,
false, if no annotated method matching the specified render
method name could be found.Annotation name name, RenderRequest Render request request, RenderResponse Render response response)
Dispatches an render request to an annotated render method.
|
| protected void | doDispatch(RenderRequest
the render request request, RenderResponse the render response response)The default implementation of this method routes the render request to:
|
| protected void | doEdit(RenderRequest
the portlet request request, RenderResponse the render response response)Helper method to serve up the |
| protected void | doHeaders(RenderRequest
the render request request, RenderResponse the render response response)Used by the render method to set the response properties and headers. |
| protected void | doHelp(RenderRequest
the portlet request request, RenderResponse the render response response)Helper method to serve up the |
| protected void | doView(RenderRequest
the portlet request request, RenderResponse the render response response)Helper method to serve up the mandatory |
| public Map | getContainerRuntimeOptions()
Implements javax. |
| public String | Returns: the default namespace defined in the portlet deployment descriptor, orXMLConstants.NULL_NS_URI is non is
defined.Implements javax. |
| public String | Returns: aString containing the value of the
initialization parametera name)String specifying the name of the
initialization parameterImplements javax. |
| public Enumeration | Returns: anEnumeration of String objects
containing the names of the portlet initialization parameters, or
an empty Enumeration if the portlet has no initialization
parameters.Implements javax. |
| protected Collection | getNextPossiblePortletModes(RenderRequest request)
Used by the render method to set the next possible portlet modes. |
| public PortletConfig | Returns: the PortletConfig object of this portletReturns the PortletConfig object of this portlet. |
| public PortletContext | Returns: the portlet application contextImplements javax. PortletContext of the portlet application the
portlet is in.
|
| public Enumeration | Returns: anEnumeration of PortletMode
objects containing the defined and supported portlet modes.MIME type mimeType)Implements javax.
Returns an
Enumeration of PortletMode objects that are defined
for the portlet for the given MIME type. |
| public String | Returns: the portlet nameImplements javax. |
| public Enumeration | getProcessingEventQNames()
Implements javax. Enumeration of QName objects,
or an empty Enumeration if the
portlet has not defined any processing events.
|
| public Map | Returns: anMap of String to QNameImplements javax.
Returns a Map of public render parameter names to their qualified names.
|
| public Enumeration | Returns: anEnumeration of String objects
containing the names of the public render parameters, or an empty
Enumeration if the portlet does not define any
public render parameters.Implements javax. Enumeration of String objects, or an empty
Enumeration if the portlet has no public render
parameters.
|
| public Enumeration | getPublishingEventQNames()
Implements javax. Enumeration of QName objects,
or an empty Enumeration if the
portlet has not defined any publishing events.
|
| public ResourceBundle | Returns: the resource bundle for the given localethe locale for which to retrieve the resource bundle locale)Implements javax. resource-bundle tag or the inlined resources defined in
the deployment descriptor.
|
| public Enumeration | getSupportedLocales()
Implements javax. Enumeration of Locale objects,
or an empty Enumeration if the
portlet has not defined any supported locales.
|
| protected String | Returns: the portlet title for this windowUsed by the render method to get the title. |
| public Enumeration | Returns: anEnumeration of WindowState
objects containing the defined and supported window states.MIME type mimeType)Implements javax.
Returns an
Enumeration of WindowState objects that are defined
for the portlet for the given MIME type. |
| public void | init(PortletConfig
a config)PortletConfig object containing the portlet
configuration and initialization parametersImplements javax. |
| public void | init()
A convenience method which can be overridden so that there's no need to
call |
| public void | processAction(ActionRequest
the action request request, ActionResponse the action response response)Implements javax. |
| public void | processEvent(EventRequest
the event request request, EventResponse the event response response)Implements javax. @ProcessEvent that matches the
event name or, if no
such method is found just sets the current render parameters on
the response.
|
| public void | render(RenderRequest
the render request request, RenderResponse the render response response)Implements javax. doHeaders method, sets the title using the
getTitle method and invokes the doDispatch
method.
|
| public void | renderHeaders(HeaderRequest
the header request request, HeaderResponse the header response response)Implements javax. |
| public void | serveResource(ResourceRequest
the resource request request, ResourceResponse the resource response response)Implements javax. |
| AUTOMATIC_RESOURCE_DISPATCH | back to summary |
|---|---|
| public static final String AUTOMATIC_RESOURCE_DISPATCH
This property is set by the container if the container
has a cached response for the given validation tag. The property can be
retrieved using the
getProperty method.
The value is
| |
| config | back to summary |
|---|---|
| private transient PortletConfig config | |
| processActionHandlingMethodsMap | back to summary |
|---|---|
| private transient Map<String, Method> processActionHandlingMethodsMap | |
| processEventHandlingMethodsMap | back to summary |
|---|---|
| private transient Map<String, Method> processEventHandlingMethodsMap | |
| renderModeHandlingMethodsMap | back to summary |
|---|---|
| private transient Map<String, Method> renderModeHandlingMethodsMap | |
| GenericPortlet | back to summary |
|---|---|
| public GenericPortlet() Does nothing. | |
| addToMap | back to summary |
|---|---|
| private void addToMap(Map<String, Method> map, String name, Method newMethod) | |
| cacheAnnotatedMethods | back to summary |
|---|---|
| private void cacheAnnotatedMethods() | |
| destroy | back to summary |
|---|---|
| public void destroy() Implements javax. Called by the portlet container to indicate to a portlet that the portlet is being taken out of service. The default implementation does nothing. | |
| dispatchAnnotatedActionMethod | back to summary |
|---|---|
| protected boolean dispatchAnnotatedActionMethod(String name, ActionRequest request, ActionResponse response) throws PortletException, IOException
Dispatches an action request to an annotated action method.
Retrieves an action method annotated with the provided name and
invokes it. Returns This method allows a portlet to extend annotation processing for the action method.
| |
| dispatchAnnotatedEventMethod | back to summary |
|---|---|
| protected boolean dispatchAnnotatedEventMethod(String name, EventRequest request, EventResponse response) throws PortletException, IOException
Dispatches an event request to an annotated event method.
Retrieves an action method annotated with the provided name and
invokes it. Returns This method allows a portlet to extend annotation processing for portlet events.
| |
| dispatchAnnotatedRenderMethod | back to summary |
|---|---|
| protected boolean dispatchAnnotatedRenderMethod(String name, RenderRequest request, RenderResponse response) throws PortletException, IOException
Dispatches an render request to an annotated render method.
Retrieves an render method annotated with the provided name and
invokes it. Returns This method allows a portlet to extend annotation processing for the render methods.
| |
| doDispatch | back to summary |
|---|---|
| protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException The default implementation of this method routes the render request to:
If the window state of this portlet is
For handling custom portlet modes the portlet should either use the
| |
| doEdit | back to summary |
|---|---|
| protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException Helper method to serve up the The default implementation throws an exception.
| |
| doHeaders | back to summary |
|---|---|
| protected void doHeaders(RenderRequest request, RenderResponse response) throws PortletException, IOException Used by the render method to set the response properties and headers. The portlet should override this method and set its response header using this method in order to ensure that they are set before anything is written to the output stream. The default implemention of this method is emtpy.
| |
| doHelp | back to summary |
|---|---|
| protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException Helper method to serve up the The default implementation throws an exception.
| |
| doView | back to summary |
|---|---|
| protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException Helper method to serve up the mandatory The default implementation throws an exception.
| |
| getContainerRuntimeOptions | back to summary |
|---|---|
| public Map Implements javax. Doc from javax. Returns the container runtime options and values for this portlet.
The portlet can set container runtime
options in the
The map returned from this method will provide the subset the
portlet container supports of the options the portlet has specified
in the
The map will contain name of the runtime option as key of type String
and the runtime options as values of type String array (
| |
| getDefaultNamespace | back to summary |
|---|---|
| public String getDefaultNamespace() Implements javax. Returns the default namespace for events and public parameters. This
namespace is defined in the portlet deployment descriptor with the
If no default namespace is defined in the portlet deployment descriptor
this methods returns the XML default namespace
| |
| getInitParameter | back to summary |
|---|---|
| public String getInitParameter(String name) Implements javax. Returns a String containing the value of the named initialization * parameter, or null if the parameter does not exist.
| |
| getInitParameterNames | back to summary |
|---|---|
| public Enumeration Implements javax. Returns the names of the portlet initialization parameters as an Enumeration of String objects, or an empty Enumeration if the portlet has no initialization parameters.
| |
| getNextPossiblePortletModes | back to summary |
|---|---|
| protected Collection Used by the render method to set the next possible portlet modes. The portlet should override this method and set the next possible portlet modes using this method in order to ensure that they are set before anything is written to the output stream.
The default implemention of this method returns
| |
| getPortletConfig | back to summary |
|---|---|
| public PortletConfig getPortletConfig() Returns the PortletConfig object of this portlet.
| |
| getPortletContext | back to summary |
|---|---|
| public PortletContext getPortletContext() Implements javax. Returns the
| |
| getPortletModes | back to summary |
|---|---|
| public Enumeration Implements javax.
Returns an
Enumeration of PortletMode objects that are defined
for the portlet for the given MIME type.
Note that a supported portlet mode may not be allowed in all situations
due to security or other reasons. To
determine whether a portlet mode is allowed during a request, use the
| |
| getPortletName | back to summary |
|---|---|
| public String getPortletName() Implements javax. Returns the name of this portlet.
| |
| getProcessingEventQNames | back to summary |
|---|---|
| public Enumeration Implements javax. Doc from javax. Returns the QNames of the processing events supported by the portlet
as an
Processing events are defined in the portlet deployment descriptor
with the
If the event was defined using the
| |
| getPublicRenderParameterDefinitions | back to summary |
|---|---|
| public Map Implements javax.
Returns a Map of public render parameter names to their qualified names.
The names are the values returned by the
PortletConfig#getPublicRenderParameterNames() method.
The values are the QName values associated with the public
render parameter.
If the public render parameter is specified in the portlet descriptor
using the
| |
| getPublicRenderParameterNames | back to summary |
|---|---|
| public Enumeration Implements javax. Returns the names of the public render parameters supported by the
portlet as an
| |
| getPublishingEventQNames | back to summary |
|---|---|
| public Enumeration Implements javax. Doc from javax. Returns the QNames of the publishing events supported by the portlet
as an
Publishing events are defined in the portlet deployment descriptor
with the Note that this call does not return any events published that have not been declared in the deployment descriptor as supported.
If the event was defined using the
| |
| getResourceBundle | back to summary |
|---|---|
| public ResourceBundle getResourceBundle(Locale locale) Implements javax. Gets the resource bundle for the given locale based on the resource
bundle defined in the deployment descriptor with
| |
| getSupportedLocales | back to summary |
|---|---|
| public Enumeration Implements javax. Doc from javax. Returns the locales supported by the portlet
as an
Supported locales are defined in the portlet deployment descriptor
with the
| |
| getTitle | back to summary |
|---|---|
| protected String getTitle(RenderRequest request) Used by the render method to get the title. The default implementation gets the title from the ResourceBundle of the PortletConfig of the portlet. The title is retrieved using the 'javax.portlet.title' resource name. Portlets can overwrite this method to provide dynamic titles (e.g. based on locale, client, and session information). Examples are:
| |
| getWindowStates | back to summary |
|---|---|
| public Enumeration Implements javax.
Returns an
Enumeration of WindowState objects that are defined
for the portlet for the given MIME type.
Note that a supported window state may not be allowed in all situations
due to security or other reasons. To
determine whether a window state is allowed during a request, use the
| |
| init | back to summary |
|---|---|
| public void init(PortletConfig config) throws PortletException Implements javax. Called by the portlet container to indicate to a portlet that the portlet is being placed into service.
The default implementation stores the
The portlet container calls the
The portlet container cannot place the portlet into service if the
| |
| init | back to summary |
|---|---|
| public void init() throws PortletException A convenience method which can be overridden so that there's no need to
call
Instead of overriding
| |
| processAction | back to summary |
|---|---|
| public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException Implements javax. Called by the portlet container to allow the portlet to process an action
request. This method is called if the client request was originated by a
URL created (by the portlet) with the
The default implementation tries to dispatch to a method
annotated with
| |
| processEvent | back to summary |
|---|---|
| public void processEvent(EventRequest request, EventResponse response) throws PortletException, IOException Implements javax. The default implementation tries to dispatch to a method
annotated with
| |
| render | back to summary |
|---|---|
| public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException Implements javax. The default implementation of this method sets the headers using the
It also evaluates the
| |
| renderHeaders | back to summary |
|---|---|
| public void renderHeaders(HeaderRequest request, HeaderResponse response) throws PortletException, IOException Implements javax. V3 method implementing the headers stage within the render phase. The default implementation does nothing.
Version 3 portlets should override this method to set HTTP headers, cookies, and
to provide markup for the overall document
| |
| serveResource | back to summary |
|---|---|
| public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException Implements javax. Default resource serving. The default implementation of this method does nothing.
However, if the reserved portlet initialization parameter
| |