Portlet API (V0.7.1) : Interface Portlet

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
Interface Portlet

All Known Implementing Classes:
  GenericPortlet

public interface Portlet

The `Portlet` interface is used by the portlet container to invoke the portlets. Every portlet has to implement this interface, either by directly implementing it, or by using an existing class implementing the Portlet interface.

A portlet is a Java technology-based web component. It is managed by the portlet container and processes requests and generates dynamic content as response. Portlets are used by portals as pluggable user interface components.

The content generated by a portlet is called a fragment. A fragment is a piece of markup (e.g. HTML, XHTML, WML) adhering to certain rules and can be aggregated with other fragments into a complete document. The content of a portlet is normally aggregated with the content of other portlets into the portal page.

The portlet container instanciates portlets, manages their lifecycle and invoking them to process requests. The lifecycle consists of:

- initializing the portlet using using the `init` method
- request processsing
- taking the portlet out of service using the `destroy` method

Request processing is divided into two types:

- action requests handled through the `processAction` method, to perform actions targeted to the portlet
- render requests handled through the `render` method, to perform the render operation

Method Summary
`void` | `destroy()` Called by the portlet container to indicate to a portlet that the portlet is being taken out of service.
`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 this portlet that a client request is triggered by an action URL to this portlet.
`void` | `render(RenderRequest request, RenderResponse response)` Notifies this portlet to generate its markup using the given request/response pair.

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

  1. Throws a `PortletException`
  2. Does not return within a time period defined by the portlet container.
  Parameters:
    `config` - a `PortletConfig` object containing the portlet's configuration and initialization parameters
  Throws:
    `PortletException` - if an exception has occurred that interferes with the portlet's 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 this portlet that a client request is triggered by an action URL to this portlet.

  Typically, in response to an action request, a portlet updates state based on the information sent in the action request parameters. In an action the portlet may:

  - issue a redirect
  - change its window state
  - change its portlet mode
  - change its persistent state
  - set render parameters

  This method is only called if the portlet has created an action URL with `RenderResponse.createActionURL()`.

  A client request triggered by an action URL translates into one action request and many render requests, one per portlet in the portal page. The action processing must be finished before the render requests can be issued.

  Parameters:
    `request` - the action request
    `response` - the action response
  Throws:
    `PortletException` - if the portlet has problems 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

  Notifies this portlet to generate its markup using the given request/response pair. Depending on the the current state and the requesting client device, the markup might differ.

  The state of a portlet may include, but is not restricted to:

  - the window state
  - the portlet mode
  - render parameter
  - request attributes
  - preference data
  - session data
  Parameters:
    `request` - the render request
    `response` - the render response
  Throws:
    `PortletException` - if the portlet has problems fulfilling the rendering request
    `UnavailableException` - if the portlet is unavailable to perform render
    `PortletSecurityException` - if the portlet cannot fullfill this request because of security reasons
    `java.io.IOException` - if the streaming causes an I/O problem

### destroy

    public void destroy()

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

  Before the portlet container calls the destroy method, it should allow any threads that are currently processing requests within the portlet object to complete execution. To avoid waiting forever, the portlet container can optionally wait for a predefined time before destroying the portlet object.

  This method enables the portlet to do the following:

  - clean up any resources that it holds (for example, memory, file handles, threads)
  - make sure that any persistent state is synchronized with the portlet current state in memory.

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