Portlet API (V0.7.1) : Class GenericPortlet

Package | Class | Tree | Deprecated | Index | Help
| Portlet API (V0.7.1)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.portlet
Class GenericPortlet

    java.lang.Object
      |
      +--javax.portlet.GenericPortlet

All Implemented Interfaces:
  Portlet, PortletConfig

public abstract class GenericPortlet
extends java.lang.Object
implements Portlet, PortletConfig

The `GenericPortlet` class provides a default implementation for the `Portlet` interface.

It is recommended not to extend the Portlet interface directly. Rather, a portlet should derive from this or any other derived class and use the provided helper methods for the different modes.

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 a set of helper methods based on the portlet mode.
`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.
`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` | `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 portlet application context.
`java.lang.String` | `getPortletName()` Returns the name of the portlet.
`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.
`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)` Notifies the portlet which is called by the portlet container that an action request has been performed.
`void` | `render(RenderRequest request, RenderResponse response)` The default implementation of this method sets the title using the `getTitle` method and performs the rendering using the `doDispatch` method.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### GenericPortlet

    public GenericPortlet()

  Does nothing.

Method Detail

### init

    public void init(PortletConfig config)
              throws PortletException

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

  The default implementation just stores the `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:

  1. it throws a `PortletException`
  2. it does not return within a time period defined by the Web server
  Specified by:
    `init` in interface `Portlet`
  Parameters:
    `config` - a `PortletConfig` object containing the portlet configuration and initialization parameters
  Throws:
    `PortletException` - if an exception has occurred that interferes with the portlet normal operation.
    `UnavailableException` - if the portlet is unavailable to perform init

### init

    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()`.

  Throws:
    `PortletException` - if an exception has occurred that interferes with the portlet normal operation.
    `UnavailableException` - if the portlet is unavailable to perform init

### processAction

    public void processAction(ActionRequest request,
                              ActionResponse response)
                       throws PortletException,
                              java.io.IOException

  Notifies the portlet which is called by the portlet container that an action request has been performed.

  The default implementation throws an exception.

  Specified by:
    `processAction` in interface `Portlet`
  Parameters:
    `request` - the action request
    `response` - the action response
  Throws:
    `PortletException` - if the portlet cannot fulfilling the request
    `UnavailableException` - if the portlet is unavailable to perform processAction
    `PortletSecurityException` - if the portlet cannot fullfill this request because of security reasons
    `IOException` - if the streaming causes an I/O problem

### render

    public void render(RenderRequest request,
                       RenderResponse response)
                throws PortletException,
                       java.io.IOException

  The default implementation of this method sets the title using the `getTitle` method and performs the rendering using the `doDispatch` method.
  Specified by:
    `render` in interface `Portlet`
  Parameters:
    `request` - the render request
    `response` - the render response
  Throws:
    `PortletException` - if the portlet cannot fulfilling the request
    `UnavailableException` - if the portlet is unavailable to perform render
    `PortletSecurityException` - if the portlet cannot fullfill this request because of security reasons
    `IOException` - if the streaming causes an I/O problem

### getTitle

    protected java.lang.String getTitle(RenderRequest request)

  Used by the render method to get the title.

  The default implementation gets the title defined in the deployment descriptor.

  Portlets can overwrite this method to provide dynamic titles (e.g. based on locale, client, and session information). Examples are:

  - language-dependant titles for multi-lingual portals
  - shorter titles for WAP phones
  - the number of messages in a mailbox portlet
  Returns:
    the portlet title for this window

### doDispatch

    protected void doDispatch(RenderRequest request,
                              RenderResponse response)
                       throws PortletException,
                              java.io.IOException

  The default implementation of this method routes the render request to a set of helper methods based on the portlet mode. 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 override this method.

  Parameters:
    `request` - the render request
    `response` - the render response
  Throws:
    `PortletException` - if the portlet cannot fulfilling the request
    `UnavailableException` - if the portlet is unavailable to perform render
    `PortletSecurityException` - if the portlet cannot fullfill this request because of security reasons
    `IOException` - if the streaming causes an I/O problem
  See Also:
    `doView(RenderRequest, RenderResponse)`, `doEdit(RenderRequest, RenderResponse)`, `doHelp(RenderRequest, RenderResponse)`

### doView

    protected void doView(RenderRequest request,
                          RenderResponse response)
                   throws PortletException,
                          java.io.IOException

  Helper method to serve up the mandatory `view` mode.

  The default implementation throws an exception.

  Parameters:
    `request` - the portlet request
    `response` - the render response
  Throws:
    `PortletException` - if the portlet cannot fulfilling the request
    `UnavailableException` - if the portlet is unavailable to perform render
    `PortletSecurityException` - if the portlet cannot fullfill this request because of security reasons
    `IOException` - if the streaming causes an I/O problem

### doEdit

    protected void doEdit(RenderRequest request,
                          RenderResponse response)
                   throws PortletException,
                          java.io.IOException

  Helper method to serve up the `edit` mode.

  The default implementation throws an exception.

  Parameters:
    `request` - the portlet request
    `response` - the render response
  Throws:
    `PortletException` - if the portlet cannot fulfilling the request
    `UnavailableException` - if the portlet is unavailable to perform render
    `PortletSecurityException` - if the portlet cannot fullfill this request because of security reasons
    `IOException` - if the streaming causes an I/O problem

### doHelp

    protected void doHelp(RenderRequest request,
                          RenderResponse response)
                   throws PortletException,
                          java.io.IOException

  Helper method to serve up the `help` mode.

  The default implementation throws an exception.

  Parameters:
    `request` - the portlet request
    `response` - the render response
  Throws:
    `PortletException` - if the portlet cannot fulfilling the request
    `UnavailableException` - if the portlet is unavailable to perform render
    `PortletSecurityException` - if the portlet cannot fullfill this request because of security reasons
    `IOException` - if the streaming causes an I/O problem

### getPortletConfig

    public PortletConfig getPortletConfig()

  Returns the PortletConfig object of this portlet.
  Returns:
    the PortletConfig object of this portlet

### destroy

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

  Specified by:
    `destroy` in interface `Portlet`

### getPortletName

    public java.lang.String getPortletName()

  Returns the name of the portlet. The portlet container needs the portlet name for administration purposes.
  Specified by:
    `getPortletName` in interface `PortletConfig`
  Returns:
    the portlet name

### getPortletContext

    public PortletContext getPortletContext()

  Returns the portlet application context.
  Specified by:
    `getPortletContext` in interface `PortletConfig`
  Returns:
    the portlet application context

### getResourceBundle

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

  If the resources are included inline the deployment descriptor, no localization support is provided by the portlet container. The defined values will be used for all Locales.

  Specified by:
    `getResourceBundle` in interface `PortletConfig`
  Returns:
    the resource bundle for the given locale

### getInitParameter

    public 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.
  Specified by:
    `getInitParameter` in interface `PortletConfig`
  Parameters:
    `name` - a `String` specifying the name of the initialization parameter
  Returns:
    a `String` containing the value of the initialization parameter
  Throws:
    `java.lang.IllegalArgumentException` - if name is `null`.

### getInitParameterNames

    public java.util.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.
  Specified by:
    `getInitParameterNames` in interface `PortletConfig`
  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.

Package | Class | Tree | Deprecated | Index | Help
| Portlet API (V0.7.1)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD