|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.portlet.GenericPortlet
public abstract class GenericPortlet
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 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.
| Constructor Summary | |
|---|---|
GenericPortlet()
Does nothing. |
|
| Method Summary | |
|---|---|
void |
destroy()
Called by the portlet container to indicate to a portlet that the portlet is being taken out of service. |
protected void |
doDispatch(RenderRequest request,
RenderResponse response)
The default implementation of this method routes the render request to: method annotated with @RenderMode and the name of the
portlet mode
a set of helper methods depending on the current portlet mode the portlet
is currently in. |
protected void |
doEdit(RenderRequest request,
RenderResponse response)
Helper method to serve up the edit mode. |
protected void |
doHeaders(RenderRequest request,
RenderResponse response)
Used by the render method to set the response properties and headers. |
protected void |
doHelp(RenderRequest request,
RenderResponse response)
Helper method to serve up the help mode. |
protected void |
doView(RenderRequest request,
RenderResponse response)
Helper method to serve up the mandatory view mode. |
java.lang.String |
getDefaultNamespace()
Returns the default namespace for events and public parameters. |
java.lang.String |
getInitParameter(java.lang.String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist. |
java.util.Enumeration<java.lang.String> |
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 java.util.Collection<PortletMode> |
getNextPossiblePortletModes(RenderRequest request)
Used by the render method to set the next possible portlet modes. |
PortletConfig |
getPortletConfig()
Returns the PortletConfig object of this portlet. |
PortletContext |
getPortletContext()
Returns the PortletContext of the portlet application the
portlet is in. |
java.lang.String |
getPortletName()
Returns the name of this portlet. |
java.util.Enumeration<javax.xml.namespace.QName> |
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. |
java.util.Enumeration<java.lang.String> |
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. |
java.util.Enumeration<javax.xml.namespace.QName> |
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. |
java.util.ResourceBundle |
getResourceBundle(java.util.Locale locale)
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. |
java.util.Enumeration<java.util.Locale> |
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 java.lang.String |
getTitle(RenderRequest request)
Used by the render method to get the title. |
void |
init()
A convenience method which can be overridden so that there's no need to call super.init(config). |
void |
init(PortletConfig config)
Called by the portlet container to indicate to a portlet that the portlet is being placed into service. |
void |
processAction(ActionRequest request,
ActionResponse response)
Called by the portlet container to allow the portlet to process an action request. |
void |
processEvent(EventRequest request,
EventResponse response)
Default event processing. |
void |
render(RenderRequest request,
RenderResponse response)
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. |
void |
serveResource(ResourceRequest request,
ResourceResponse response)
Default resource serving. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GenericPortlet()
| Method Detail |
|---|
public void init(PortletConfig config)
throws PortletException
The default implementation stores the PortletConfig object
and checks for annotated methods with the annotations
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:
PortletException
init in interface Portletconfig - a PortletConfig object containing the portlet
configuration and initialization parameters
PortletException - if an exception has occurred that interferes with the
portlet normal operation.
UnavailableException - if the portlet cannot perform the initialization at this
time.
public void init()
throws PortletException
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().
PortletException - if an exception has occurred that interferes with the
portlet normal operation.
UnavailableException - if the portlet is unavailable to perform init
public void processAction(ActionRequest request,
ActionResponse response)
throws PortletException,
java.io.IOException
RenderResponse.createActionURL() method.
The default implementation throws an exception.
processAction in interface Portletrequest - the action requestresponse - the action response
PortletException - if the portlet cannot fulfilling the request
UnavailableException - if the portlet is unavailable to process the action at
this time
PortletSecurityException - if the portlet cannot fullfill this request because of
security reasons
java.io.IOException - if the streaming causes an I/O problem
public void render(RenderRequest request,
RenderResponse response)
throws PortletException,
java.io.IOException
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.
render in interface Portletrequest - the render requestresponse - the render response
PortletException - if the portlet cannot fulfilling the request
UnavailableException - if the portlet is unavailable to perform render at this
time
PortletSecurityException - if the portlet cannot fullfill this request because of
security reasons
java.io.IOException - if the streaming causes an I/O problemprotected java.lang.String getTitle(RenderRequest request)
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:
java.lang.IllegalStateException - if no portlet config object is available
protected void doDispatch(RenderRequest request,
RenderResponse response)
throws PortletException,
java.io.IOException
@RenderMode and the name of the
portlet modedoView for handling view requestsdoEdit for handling edit requestsdoHelp 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.
request - the render requestresponse - the render response
PortletException - if the portlet cannot fulfilling the request
UnavailableException - if the portlet is unavailable to perform render at this
time
PortletSecurityException - if the portlet cannot fullfill this request because of
security reasons
java.io.IOException - if the streaming causes an I/O problemdoView(RenderRequest, RenderResponse),
doEdit(RenderRequest, RenderResponse),
doHelp(RenderRequest, RenderResponse)
protected void doView(RenderRequest request,
RenderResponse response)
throws PortletException,
java.io.IOException
view mode.
The default implementation throws an exception.
request - the portlet requestresponse - the render response
PortletException - if the portlet cannot fulfilling the request
UnavailableException - if the portlet is unavailable to perform render at this
time
PortletSecurityException - if the portlet cannot fullfill this request because of
security reasons
java.io.IOException - if the streaming causes an I/O problem
protected void doEdit(RenderRequest request,
RenderResponse response)
throws PortletException,
java.io.IOException
edit mode.
The default implementation throws an exception.
request - the portlet requestresponse - the render response
PortletException - if the portlet cannot fulfilling the request
UnavailableException - if the portlet is unavailable to perform render at this
time
PortletSecurityException - if the portlet cannot fullfill this request because of
security reasons
java.io.IOException - if the streaming causes an I/O problem
protected void doHelp(RenderRequest request,
RenderResponse response)
throws PortletException,
java.io.IOException
help mode.
The default implementation throws an exception.
request - the portlet requestresponse - the render response
PortletException - if the portlet cannot fulfilling the request
UnavailableException - if the portlet is unavailable to perform render at this
time
PortletSecurityException - if the portlet cannot fullfill this request because of
security reasons
java.io.IOException - if the streaming causes an I/O problempublic PortletConfig getPortletConfig()
public void destroy()
The default implementation does nothing.
destroy in interface Portletpublic java.lang.String getPortletName()
getPortletName in interface PortletConfigPortletConfig.getPortletName()public PortletContext getPortletContext()
PortletContext of the portlet application the
portlet is in.
getPortletContext in interface PortletConfigPortletContextpublic java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
resource-bundle tag or the inlined resources defined in
the deployment descriptor.
getResourceBundle in interface PortletConfiglocale - the locale for which to retrieve the resource bundle
public java.lang.String getInitParameter(java.lang.String name)
getInitParameter in interface PortletConfigname - a String specifying the name of the
initialization parameter
String containing the value of the
initialization parameter
java.lang.IllegalArgumentException - if name is null.public java.util.Enumeration<java.lang.String> getInitParameterNames()
getInitParameterNames in interface PortletConfigEnumeration of String objects
containing the names of the portlet initialization parameters, or
an empty Enumeration if the portlet has no initialization
parameters.public java.util.Enumeration<javax.xml.namespace.QName> getProcessingEventQNames()
PortletConfigEnumeration 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.
getProcessingEventQNames in interface PortletConfigEnumeration 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.public java.util.Enumeration<javax.xml.namespace.QName> getPublishingEventQNames()
PortletConfigEnumeration 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.
getPublishingEventQNames in interface PortletConfigEnumeration 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.public java.util.Enumeration<java.util.Locale> getSupportedLocales()
PortletConfigEnumeration 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.
getSupportedLocales in interface PortletConfigEnumeration of Locale
objects containing the supported locales,
or an empty Enumeration if the
portlet has not defined any supported locales in
the deployment descriptor.
public void serveResource(ResourceRequest request,
ResourceResponse response)
throws PortletException,
java.io.IOException
The default implemention of this method is to call a RequestDispatcher.foward with the ResourceID of the ResourceRequest.
If no ResourceID is set on the resource URL the default implementation does nothing.
serveResource in interface ResourceServingPortletrequest - the resource requestresponse - the resource response
PortletException - if the portlet has problems fulfilling the
rendering request
UnavailableException - if the portlet is unavailable to perform render at this time
PortletSecurityException - if the portlet cannot fullfill this request because of security reasons
java.io.IOException - if the streaming causes an I/O problem
public void processEvent(EventRequest request,
EventResponse response)
throws PortletException,
java.io.IOException
@ProcessEvent(name=) and the signaturepublic void (EventRequest, EventResponse) throws PortletException, java.io.IOException .
processEvent in interface EventPortletrequest - the event requestresponse - the event response
PortletException - if the portlet has problems fulfilling the
request
UnavailableException - if the portlet is unavailable to process the event at this time
PortletSecurityException - if the portlet cannot fullfill this request because of security reasons
java.io.IOException - if the streaming causes an I/O problemEventPortlet.processEvent(javax.portlet.EventRequest,
javax.portlet.EventResponse)
protected void doHeaders(RenderRequest request,
RenderResponse response)
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.
protected java.util.Collection<PortletMode> getNextPossiblePortletModes(RenderRequest request)
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.
public java.util.Enumeration<java.lang.String> getPublicRenderParameterNames()
Enumeration of String objects, or an empty
Enumeration if the portlet has no public render
parameters.
getPublicRenderParameterNames in interface PortletConfigEnumeration 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.PortletConfig.getPublicRenderParameterNames()public java.lang.String getDefaultNamespace()
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.
getDefaultNamespace in interface PortletConfigXMLConstants.NULL_NS_URI is non is
defined.PortletConfig.getDefaultNamespace()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||