Top Description Fields Constructors Methods
javax.portlet

public abstract Class GenericPortlet

extends Object
implements Portlet, PortletConfig, EventPortlet, ResourceServingPortlet, HeaderPortlet
Class Inheritance
All Implemented Interfaces
javax.portlet.HeaderPortlet, javax.portlet.ResourceServingPortlet, javax.portlet.EventPortlet, javax.portlet.PortletConfig, javax.portlet.Portlet
Imports
java.io.IOException, java.lang.annotation.Annotation, java.lang.reflect.Method, .InvocationTargetException, java.util.Collection, .Enumeration, .HashMap, .ArrayList, .Locale, .Map, javax.xml.namespace.QName

The 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:

or override at least one method, usually one of the following:

Normally 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.

Field Summary

Modifier and TypeField 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<String, Method>
private transient Map<String, Method>
private transient Map<String, Method>

Constructor Summary

AccessConstructor and Description
public
GenericPortlet()

Does nothing.

Method Summary

Modifier and TypeMethod and Description
private void
addToMap(Map<String, Method> map, String name, Method newMethod)

private void
public void
destroy()

Implements javax.portlet.Portlet.destroy.

Called by the portlet container to indicate to a portlet that the portlet is being taken out of service.
protected boolean

Returns:

true, if the request was dispatched, false, if no annotated method matching the specified action method name could be found.
dispatchAnnotatedActionMethod
(String
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.
dispatchAnnotatedEventMethod
(String
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.
dispatchAnnotatedRenderMethod
(String
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:

  1. method annotated with @RenderMode and the name of the portlet mode
  2. a set of helper methods depending on the current portlet mode the portlet is currently in. These methods are:
    • doView for handling view requests
    • doEdit for handling edit requests
    • doHelp for handling help requests
protected void
doEdit(RenderRequest
the portlet request
request
,
RenderResponse
the render response
response
)

Helper method to serve up the edit mode.

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 help mode.

protected void
doView(RenderRequest
the portlet request
request
,
RenderResponse
the render response
response
)

Helper method to serve up the mandatory view mode.

public Map<String, String[]>
getContainerRuntimeOptions()

Implements javax.portlet.PortletConfig.getContainerRuntimeOptions.

Returns the container runtime options and values for this portlet.
public String

Returns:

the default namespace defined in the portlet deployment descriptor, or XMLConstants.NULL_NS_URI is non is defined.
getDefaultNamespace
()

Implements javax.portlet.PortletConfig.getDefaultNamespace.

Returns the default namespace for events and public parameters.
public String

Returns:

a String containing the value of the initialization parameter
getInitParameter
(String
a String specifying the name of the initialization parameter
name
)

Implements javax.portlet.PortletConfig.getInitParameter.

Returns a String containing the value of the named initialization * parameter, or null if the parameter does not exist.
public Enumeration<String>

Returns:

an Enumeration of String objects containing the names of the portlet initialization parameters, or an empty Enumeration if the portlet has no initialization parameters.
getInitParameterNames
()

Implements javax.portlet.PortletConfig.getInitParameterNames.

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.
protected Collection<PortletMode>
getNextPossiblePortletModes(RenderRequest request)

Used by the render method to set the next possible portlet modes.

public PortletConfig

Returns:

the PortletConfig object of this portlet
getPortletConfig
()

Returns the PortletConfig object of this portlet.

public PortletContext

Returns:

the portlet application context
getPortletContext
()

Implements javax.portlet.PortletConfig.getPortletContext.

Returns the PortletContext of the portlet application the portlet is in.
public Enumeration<PortletMode>

Returns:

an Enumeration of PortletMode objects containing the defined and supported portlet modes.
getPortletModes
(String
MIME type
mimeType
)

Implements javax.portlet.PortletConfig.getPortletModes.

Returns an Enumeration of PortletMode objects that are defined for the portlet for the given MIME type.
public String

Returns:

the portlet name
getPortletName
()

Implements javax.portlet.PortletConfig.getPortletName.

Returns the name of this portlet.
public Enumeration<QName>
getProcessingEventQNames()

Implements javax.portlet.PortletConfig.getProcessingEventQNames.

Returns the QNames of the processing events supported by the portlet as an Enumeration of QName objects, or an empty Enumeration if the portlet has not defined any processing events.
public Map<String, QName>

Returns:

an Map of String to QName
getPublicRenderParameterDefinitions
()

Implements javax.portlet.PortletConfig.getPublicRenderParameterDefinitions.

Returns a Map of public render parameter names to their qualified names.
public Enumeration<String>

Returns:

an Enumeration 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.
getPublicRenderParameterNames
()

Implements javax.portlet.PortletConfig.getPublicRenderParameterNames.

Returns the names of the public render parameters supported by the portlet as an Enumeration of String objects, or an empty Enumeration if the portlet has no public render parameters.
public Enumeration<QName>
getPublishingEventQNames()

Implements javax.portlet.PortletConfig.getPublishingEventQNames.

Returns the QNames of the publishing events supported by the portlet as an 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 locale
getResourceBundle
(Locale
the locale for which to retrieve the resource bundle
locale
)

Implements javax.portlet.PortletConfig.getResourceBundle.

Gets the resource bundle for the given locale based on the resource bundle defined in the deployment descriptor with resource-bundle tag or the inlined resources defined in the deployment descriptor.
public Enumeration<Locale>
getSupportedLocales()

Implements javax.portlet.PortletConfig.getSupportedLocales.

Returns the locales supported by the portlet as an 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 window
getTitle
(RenderRequest request)

Used by the render method to get the title.

public Enumeration<WindowState>

Returns:

an Enumeration of WindowState objects containing the defined and supported window states.
getWindowStates
(String
MIME type
mimeType
)

Implements javax.portlet.PortletConfig.getWindowStates.

Returns an Enumeration of WindowState objects that are defined for the portlet for the given MIME type.
public void
init(PortletConfig
a PortletConfig object containing the portlet configuration and initialization parameters
config
)

Implements javax.portlet.Portlet.init.

Called by the portlet container to indicate to a portlet that the portlet is being placed into service.
public void
init()

A convenience method which can be overridden so that there's no need to call super.init(config).

public void
processAction(ActionRequest
the action request
request
,
ActionResponse
the action response
response
)

Implements javax.portlet.Portlet.processAction.

Called by the portlet container to allow the portlet to process an action request.
public void
processEvent(EventRequest
the event request
request
,
EventResponse
the event response
response
)

Implements javax.portlet.EventPortlet.processEvent.

The default implementation tries to dispatch to a method annotated with @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.portlet.Portlet.render.

The default implementation of this method sets the headers using the 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.portlet.HeaderPortlet.renderHeaders.

V3 method implementing the headers stage within the render phase.
public void
serveResource(ResourceRequest
the resource request
request
,
ResourceResponse
the resource response
response
)

Implements javax.portlet.ResourceServingPortlet.serveResource.

Default resource serving.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AUTOMATIC_RESOURCE_DISPATCHback 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 "javax.portlet.automaticResourceDispatching".

Since
3.0
configback to summary
private transient PortletConfig config
processActionHandlingMethodsMapback to summary
private transient Map<String, Method> processActionHandlingMethodsMap
processEventHandlingMethodsMapback to summary
private transient Map<String, Method> processEventHandlingMethodsMap
renderModeHandlingMethodsMapback to summary
private transient Map<String, Method> renderModeHandlingMethodsMap

Constructor Detail

GenericPortletback to summary
public GenericPortlet()

Does nothing.

Method Detail

addToMapback to summary
private void addToMap(Map<String, Method> map, String name, Method newMethod)
cacheAnnotatedMethodsback to summary
private void cacheAnnotatedMethods()
destroyback to summary
public void destroy()

Implements javax.portlet.Portlet.destroy.

Called by the portlet container to indicate to a portlet that the portlet is being taken out of service.

The default implementation does nothing.

dispatchAnnotatedActionMethodback 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 true if the method could be successfully located and invoked, and false if no annotated action method by that name could be found.

This method allows a portlet to extend annotation processing for the action method.

Parameters
name:String

Annotation name

request:ActionRequest

Action request

response:ActionResponse

Action response

Returns:boolean

true, if the request was dispatched, false, if no annotated method matching the specified action method name could be found.

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to process the action at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
Since
3.0
See Also
processAction(ActionRequest, ActionResponse)
dispatchAnnotatedEventMethodback 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 true if the method could be successfully located and invoked, and false if no annotated event method by that name could be found.

This method allows a portlet to extend annotation processing for portlet events.

Parameters
name:String

Annotation name

request:EventRequest

Event request

response:EventResponse

Event response

Returns:boolean

true, if the request was dispatched, false, if no annotated method matching the specified event method name could be found.

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to process the action at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
Since
3.0
See Also
processEvent(EventRequest, EventResponse)
dispatchAnnotatedRenderMethodback 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 true if the method could be successfully located and invoked, and false if no annotated render method by that name could be found.

This method allows a portlet to extend annotation processing for the render methods.

Parameters
name:String

Annotation name

request:RenderRequest

Render request

response:RenderResponse

Render response

Returns:boolean

true, if the request was dispatched, false, if no annotated method matching the specified render method name could be found.

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to process the render at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
Since
3.0
See Also
doDispatch(RenderRequest, RenderResponse)
doDispatchback to summary
protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException

The default implementation of this method routes the render request to:

  1. method annotated with @RenderMode and the name of the portlet mode
  2. a set of helper methods depending on the current portlet mode the portlet is currently in. These methods are:
    • doView for handling view requests
    • doEdit for handling edit requests
    • doHelp for handling help requests

If the window state of this portlet is minimized, this method does not invoke any of the portlet mode rendering methods.

For handling custom portlet modes the portlet should either use the @RenderMode annotation or override this method. Note that the annotated methods needs to be public in order to be allowed to be called by GenericPortlet.

Parameters
request:RenderRequest

the render request

response:RenderResponse

the render response

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to perform render at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
See Also
doView(RenderRequest, RenderResponse), doEdit(RenderRequest, RenderResponse), doHelp(RenderRequest, RenderResponse)
doEditback to summary
protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException

Helper method to serve up the edit mode.

The default implementation throws an exception.

Parameters
request:RenderRequest

the portlet request

response:RenderResponse

the render response

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to perform render at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
doHeadersback 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.

Parameters
request:RenderRequest

the render request

response:RenderResponse

the render response

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to perform render at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
Since
2.0
doHelpback to summary
protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException

Helper method to serve up the help mode.

The default implementation throws an exception.

Parameters
request:RenderRequest

the portlet request

response:RenderResponse

the render response

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to perform render at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
doViewback to summary
protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException

Helper method to serve up the mandatory view mode.

The default implementation throws an exception.

Parameters
request:RenderRequest

the portlet request

response:RenderResponse

the render response

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to perform render at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
getContainerRuntimeOptionsback to summary
public Map<String, String[]> getContainerRuntimeOptions()

Implements javax.portlet.PortletConfig.getContainerRuntimeOptions.

Doc from javax.portlet.PortletConfig.getContainerRuntimeOptions.

Returns the container runtime options and values for this portlet.

The portlet can set container runtime options in the portlet.xml via the container-runtime-option element with a name and a value on the application and portlet level.
If a container runtime option is set on the portlet application level and on the portlet level with the same name the setting on the portlet level takes precedence and overwrites the one set on the portal application level.

The map returned from this method will provide the subset the portlet container supports of the options the portlet has specified in the portlet.xml. Options that the portlet container does not support will not be returned in this map.

The map will contain name of the runtime option as key of type String and the runtime options as values of type String array (String[]) with the values specified in the portlet.xml deployment descriptor.

Returns:Map<String, String[]>

an immutable Map containing portlet container runtime options names as keys and the container runtime values as map values, or an empty Map if no portlet container runtime options are set in the portlet.xml or supported by this portlet container. The keys in the map are of type String. The values in the map are of type String array (String[]).

getDefaultNamespaceback to summary
public String getDefaultNamespace()

Implements javax.portlet.PortletConfig.getDefaultNamespace.

Returns the default namespace for events and public parameters. This namespace is defined in the portlet deployment descriptor with the default-namespace element.

If no default namespace is defined in the portlet deployment descriptor this methods returns the XML default namespace XMLConstants.NULL_NS_URI.

Returns:String

the default namespace defined in the portlet deployment descriptor, or XMLConstants.NULL_NS_URI is non is defined.

See Also
javax.portlet.PortletConfig#getDefaultNamespace()
getInitParameterback to summary
public String getInitParameter(String name)

Implements javax.portlet.PortletConfig.getInitParameter.

Returns a String containing the value of the named initialization * parameter, or null if the parameter does not exist.

Parameters
name:String

a String specifying the name of the initialization parameter

Returns:String

a String containing the value of the initialization parameter

Exceptions
IllegalArgumentException:
if name is null.
getInitParameterNamesback to summary
public Enumeration<String> getInitParameterNames()

Implements javax.portlet.PortletConfig.getInitParameterNames.

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.

Returns:Enumeration<String>

an Enumeration of String objects containing the names of the portlet initialization parameters, or an empty Enumeration if the portlet has no initialization parameters.

getNextPossiblePortletModesback to summary
protected Collection<PortletMode> getNextPossiblePortletModes(RenderRequest request)

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 null.

Since
2.0
getPortletConfigback to summary
public PortletConfig getPortletConfig()

Returns the PortletConfig object of this portlet.

Returns:PortletConfig

the PortletConfig object of this portlet

getPortletContextback to summary
public PortletContext getPortletContext()

Implements javax.portlet.PortletConfig.getPortletContext.

Returns the PortletContext of the portlet application the portlet is in.

Returns:PortletContext

the portlet application context

getPortletModesback to summary
public Enumeration<PortletMode> getPortletModes(String mimeType)

Implements javax.portlet.PortletConfig.getPortletModes.

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 PortletRequest#isPortletModeAllowed(PortletMode) method. To determine which portlet modes are supported by the portal, use PortalContext#getSupportedPortletModes()

Parameters
mimeType:String

MIME type

Returns:Enumeration<PortletMode>

an Enumeration of PortletMode objects containing the defined and supported portlet modes.

Since
3.0
See Also
PortletMode, PortletRequest#isPortletModeAllowed(PortletMode)
getPortletNameback to summary
public String getPortletName()

Implements javax.portlet.PortletConfig.getPortletName.

Returns the name of this portlet.

Returns:String

the portlet name

See Also
PortletConfig#getPortletName()
getProcessingEventQNamesback to summary
public Enumeration<QName> getProcessingEventQNames()

Implements javax.portlet.PortletConfig.getProcessingEventQNames.

Doc from javax.portlet.PortletConfig.getProcessingEventQNames.

Returns the QNames of the processing events supported by the portlet as an Enumeration of QName objects, or an empty Enumeration if the portlet has not defined any processing events.

Processing events are defined in the portlet deployment descriptor with the supported-processing-event element.

If the event was defined using the name element instead of the qname element the defined default namespace is added as namespace for the returned QName.

Returns:Enumeration<QName>

an Enumeration of QName objects containing the names of the processing events, or an empty Enumeration if the portlet has not defined any support for processing events in the deployment descriptor.

getPublicRenderParameterDefinitionsback to summary
public Map<String, QName> getPublicRenderParameterDefinitions()

Implements javax.portlet.PortletConfig.getPublicRenderParameterDefinitions.

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 <.name>. tag rather than the <.qname>. tag, the QName is built from the default namespace from the deployment descriptor together with the value from the <.name>. tag.

Returns:Map<String, QName>

an Map of String to QName

Since
3.0
See Also
PortletConfig#getPublicRenderParameterNames()
getPublicRenderParameterNamesback to summary
public Enumeration<String> getPublicRenderParameterNames()

Implements javax.portlet.PortletConfig.getPublicRenderParameterNames.

Returns the names of the public render parameters supported by the portlet as an Enumeration of String objects, or an empty Enumeration if the portlet has no public render parameters.

Returns:Enumeration<String>

an Enumeration 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.

See Also
javax.portlet.PortletConfig#getPublicRenderParameterNames()
getPublishingEventQNamesback to summary
public Enumeration<QName> getPublishingEventQNames()

Implements javax.portlet.PortletConfig.getPublishingEventQNames.

Doc from javax.portlet.PortletConfig.getPublishingEventQNames.

Returns the QNames of the publishing events supported by the portlet as an Enumeration of QName objects, or an empty Enumeration if the portlet has not defined any publishing events.

Publishing events are defined in the portlet deployment descriptor with the supported-publishing-event element.

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 name element instead of the qname element the defined default namespace is added as namespace for the returned QName.

Returns:Enumeration<QName>

an Enumeration of QName objects containing the names of the publishing events, or an empty Enumeration if the portlet has not defined any support for publishing events in the deployment descriptor.

getResourceBundleback to summary
public ResourceBundle getResourceBundle(Locale locale)

Implements javax.portlet.PortletConfig.getResourceBundle.

Gets the resource bundle for the given locale based on the resource bundle defined in the deployment descriptor with resource-bundle tag or the inlined resources defined in the deployment descriptor.

Parameters
locale:Locale

Doc from javax.portlet.PortletConfig.getResourceBundle.

the locale for which to retrieve the resource bundle

Returns:ResourceBundle

the resource bundle for the given locale

getSupportedLocalesback to summary
public Enumeration<Locale> getSupportedLocales()

Implements javax.portlet.PortletConfig.getSupportedLocales.

Doc from javax.portlet.PortletConfig.getSupportedLocales.

Returns the locales supported by the portlet as an Enumeration of Locale objects, or an empty Enumeration if the portlet has not defined any supported locales.

Supported locales are defined in the portlet deployment descriptor with the supported-locale element.

Returns:Enumeration<Locale>

an Enumeration of Locale objects containing the supported locales, or an empty Enumeration if the portlet has not defined any supported locales in the deployment descriptor.

getTitleback 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:

  • language-dependent titles for multi-lingual portals
  • shorter titles for WAP phones
  • the number of messages in a mailbox portlet
Returns:String

the portlet title for this window

Exceptions
IllegalStateException:
if no portlet config object is available
getWindowStatesback to summary
public Enumeration<WindowState> getWindowStates(String mimeType)

Implements javax.portlet.PortletConfig.getWindowStates.

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 PortletRequest#isWindowStateAllowed(WindowState) method. To determine which window states are supported by the portal, use PortalContext#getSupportedWindowStates().

Parameters
mimeType:String

MIME type

Returns:Enumeration<WindowState>

an Enumeration of WindowState objects containing the defined and supported window states.

Since
3.0
See Also
WindowState, PortletRequest#isWindowStateAllowed(WindowState)
initback to summary
public void init(PortletConfig config) throws PortletException

Implements javax.portlet.Portlet.init.

Called by the portlet container to indicate to a portlet that the portlet is being placed into service.

The default implementation stores the PortletConfig object and checks for annotated methods with the annotations

  • @ProcessAction
  • @ProcessEvent
  • @RenderMode
and stores these in a hashmap for later dispatching.

The portlet container calls the init method exactly once after instantiating the portlet. The init method must complete successfully before the portlet can receive any requests.

The portlet container cannot place the portlet into service if the init method does one of the following:

  1. it throws a PortletException
  2. it does not return within a time period defined by the Web server
Parameters
config:PortletConfig

a PortletConfig object containing the portlet configuration and initialization parameters

Exceptions
PortletException:
if an exception has occurred that interferes with the portlet normal operation.
UnavailableException:
if the portlet cannot perform the initialization at this time.
initback to summary
public void init() throws PortletException

A convenience method which can be overridden so that there's no need to call super.init(config).

Instead of overriding init(PortletConfig), simply override this method and it will be called by GenericPortlet.init(PortletConfig config). The PortletConfig object can still be retrieved via getPortletConfig.

Exceptions
PortletException:
if an exception has occurred that interferes with the portlet normal operation.
UnavailableException:
if the portlet is unavailable to perform init
processActionback to summary
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException

Implements javax.portlet.Portlet.processAction.

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 RenderResponse.createActionURL() method.

The default implementation tries to dispatch to a method annotated with @ProcessAction that matches the action parameter value ActionRequest.ACTION_NAME or, if no such method is found throws a PortletException.
Note that the annotated methods needs to be public in order to be allowed to be called by GenericPortlet.

Parameters
request:ActionRequest

the action request

response:ActionResponse

the action response

Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to process the action at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
processEventback to summary
public void processEvent(EventRequest request, EventResponse response) throws PortletException, IOException

Implements javax.portlet.EventPortlet.processEvent.

The default implementation tries to dispatch to a method annotated with @ProcessEvent that matches the event name or, if no such method is found just sets the current render parameters on the response.
Note that the annotated methods needs to be public in order to be allowed to be called by GenericPortlet.

Parameters
request:EventRequest

Doc from javax.portlet.EventPortlet.processEvent.

the event request

response:EventResponse

Doc from javax.portlet.EventPortlet.processEvent.

the event response

Annotations
@SuppressWarnings:deprecation
Exceptions
PortletException:

Doc from javax.portlet.EventPortlet.processEvent.

if the portlet has problems fulfilling the request

IOException:

Doc from javax.portlet.EventPortlet.processEvent.

if the streaming causes an I/O problem

Since
2.0
See Also
javax.portlet.EventPortlet#processEvent(javax.portlet.EventRequest, javax.portlet.EventResponse)
renderback to summary
public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException

Implements javax.portlet.Portlet.render.

The default implementation of this method sets the headers using the doHeaders method, sets the title using the getTitle method and invokes the doDispatch method.

It also evaluates the RENDER_PART request attribute and if set calls the doHeaders, getNextPossiblePortletModes and getTitle methods for the RENDER_HEADERS part and the doDispatch method for the RENDER_MARKUP part.
If the RENDER_PART request attribute is not set all of the above methods will be called.

Parameters
request:RenderRequest

the render request

response:RenderResponse

the render response

Annotations
@SuppressWarnings:deprecation
Exceptions
PortletException:
if the portlet cannot fulfill the request
IOException:
if the streaming causes an I/O problem
UnavailableException:
if the portlet is unavailable to perform render at this time
PortletSecurityException:
if the portlet cannot fulfill this request due to security reasons
renderHeadersback to summary
public void renderHeaders(HeaderRequest request, HeaderResponse response) throws PortletException, IOException

Implements javax.portlet.HeaderPortlet.renderHeaders.

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 HEAD section.

Parameters
request:HeaderRequest

Doc from javax.portlet.HeaderPortlet.renderHeaders.

the header request

response:HeaderResponse

Doc from javax.portlet.HeaderPortlet.renderHeaders.

the header response

Exceptions
PortletException:

Doc from javax.portlet.HeaderPortlet.renderHeaders.

if the portlet has problems fulfilling the request

IOException:

Doc from javax.portlet.HeaderPortlet.renderHeaders.

if the streaming causes an I/O problem

serveResourceback to summary
public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException

Implements javax.portlet.ResourceServingPortlet.serveResource.

Default resource serving.

The default implementation of this method does nothing.

However, if the reserved portlet initialization parameter AUTOMATIC_RESOURCE_DISPATCH (= "javax.portlet.automaticResourceDispatching") is set to true, the default implementation will perform a PortletRequestDispatcher.forward to the location designated by the ResourceID of the ResourceRequest. If no ResourceID is set on the resource URL the default implementation does nothing.

Parameters
request:ResourceRequest

Doc from javax.portlet.ResourceServingPortlet.serveResource.

the resource request

response:ResourceResponse

Doc from javax.portlet.ResourceServingPortlet.serveResource.

the resource response

Exceptions
PortletException:

Doc from javax.portlet.ResourceServingPortlet.serveResource.

if the portlet has problems fulfilling the rendering request

IOException:

Doc from javax.portlet.ResourceServingPortlet.serveResource.

if the streaming causes an I/O problem

Since
2.0