public abstract class GenericPortlet extends Object implements Portlet
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: | Modifier | Constructor and Description |
|---|---|
protected |
GenericPortlet()
Does nothing.
|
| Modifier and Type | Method and Description |
|---|---|
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 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 |
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. |
String |
getInitParameter(String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not
exist.
|
Enumeration |
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.
|
PortletConfig |
getPortletConfig()
Returns the PortletConfig object of this portlet.
|
PortletContext |
getPortletContext()
Returns the
PortletContext of the portlet application the portlet is in. |
String |
getPortletName()
Returns the name of this portlet.
|
ResourceBundle |
getResourceBundle(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. |
protected 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 |
render(RenderRequest request,
RenderResponse response)
The default implementation of this method sets the title using the
getTitle method and invokes the
doDispatch method. |
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 initpublic PortletConfig getPortletConfig()
public String getPortletName()
PortletConfig.getPortletName()public PortletContext getPortletContext()
PortletContext of the portlet application the portlet is in.protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
doView for handling
view requests doEdit for handling edit requests doHelp
for handling help requests minimized, this method does not invoke any of the portlet mode
rendering methods.
For handling custom portlet modes the portlet should override this method.request - the render requestresponse - the render responsePortletException - if the portlet cannot fulfilling the requestUnavailableException - if the portlet is unavailable to perform render at this timePortletSecurityException - if the portlet cannot fullfill this request because of security reasonsIOException - 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, PortletSecurityException, IOException
view mode.
The default implementation throws an exception.request - the portlet requestresponse - the render responsePortletException - if the portlet cannot fulfilling the requestUnavailableException - if the portlet is unavailable to perform render at this timePortletSecurityException - if the portlet cannot fullfill this request because of security reasonsIOException - if the streaming causes an I/O problemprotected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
help mode.
The default implementation throws an exception.request - the portlet requestresponse - the render responsePortletException - if the portlet cannot fulfilling the requestUnavailableException - if the portlet is unavailable to perform render at this timePortletSecurityException - if the portlet cannot fullfill this request because of security reasonsIOException - if the streaming causes an I/O problemprotected void doEdit(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
edit mode.
The default implementation throws an exception.request - the portlet requestresponse - the render responsePortletException - if the portlet cannot fulfilling the requestUnavailableException - if the portlet is unavailable to perform render at this timePortletSecurityException - if the portlet cannot fullfill this request because of security reasonsIOException - if the streaming causes an I/O problempublic ResourceBundle getResourceBundle(Locale locale)
resource-bundle tag or the inlined resources defined in the deployment descriptor.protected String getTitle(RenderRequest request)
public String getInitParameter(String name) throws IllegalArgumentException
name - a String specifying the name of the initialization parameterString containing the value of the initialization parameterIllegalArgumentException - if name is null.public Enumeration getInitParameterNames()
Enumeration of String objects containing the names of the portlet
initialization parameters, or an empty Enumeration if the portlet has no initialization parameters.public void init(PortletConfig config) throws PortletException
PortletConfig object. 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
parametersPortletException - 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 processAction(ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
RenderResponse.createActionURL()
method.
The default implementation throws an exception.processAction in interface Portletrequest - the action requestresponse - the action responsePortletException - if the portlet cannot fulfilling the requestUnavailableException - if the portlet is unavailable to process the action at this timePortletSecurityException - if the portlet cannot fullfill this request because of security reasonsIOException - if the streaming causes an I/O problempublic void render(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
getTitle method and invokes the
doDispatch method.render in interface Portletrequest - the render requestresponse - the render responsePortletException - if the portlet cannot fulfilling the requestUnavailableException - if the portlet is unavailable to perform render at this timePortletSecurityException - if the portlet cannot fullfill this request because of security reasonsIOException - if the streaming causes an I/O problemCopyright © 2003-2019 GateIn. All Rights Reserved.