Overview | Package | Class | Tree | Deprecated | Index | Help
| Portlet API 2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.jetspeed.portlet
Interface PortletContext

public interface PortletContext

The `PortletContext` interface defines a portlet's view of the portlet container within which each portlet is running. The `PortletContext` also allows a portlet to access resources available to it. Using the context, a portlet can access the portlet log, and obtain URL references to resources.

Method Summary
`void` | `addListener(MessageListener listener)` Adds the given message listener to this context.
`Object` | `getAttribute(String name)` Returns the attribute value with the given name, or `null` if no such attribute exists.
`Enumeration` | `getAttributeNames()` Returns an enumeration of the attribute names that this portlet context is aware of.
`String` | `getContainerInfo()` Returns the name and version of the portlet container which the portlet is running in.
`String` | `getInitParameter(String name)` Returns the value of the context-wide initialization parameter with the given name, or `null` if the parameter does not exist.
`Enumeration` | `getInitParameterNames()` Returns the names of this context’s initialization parameters as an enumeration, or an empty enumeration if this context has no initialization parameters.
`PortletLog` | `getLog()` Returns the portlet log which allows the portlet to write informational, warning, or error messages to a log.
`int` | `getMajorVersion()` Returns the major version of the Portlet API that this portlet container supports.
`int` | `getMinorVersion()` Returns the minor version of the Portlet API that this portlet container supports.
`InputStream` | `getResourceAsStream(String path)` Returns the resource located at the given path as an `InputStream` object.
`InputStream` | `getResourceAsStream(String path, Locale locale)` Returns the resource with the given locale located at the given path as an `InputStream` object.
`String` | `getText(String key, Locale locale)` Returns the localized text resource with the given key and using the given locale.
`void` | `include(String path, PortletRequest request, PortletResponse response)` Allows the portlet to delegate the rendering to another resource as specified by the given path.
`void` | `removeListener(MessageListener listener)` Removes the given message listener from this context.
`void` | `send(String aPortletName, PortletMessage aMessage)` Sends the given message to all portlets on the same page that have the given name.

Method Detail

### getInitParameter

    public String getInitParameter(String name)

  Returns the value of the context-wide initialization parameter with the given name, or `null` if the parameter does not exist.

  This method can make available configuration information useful to all portlets.

  Parameters:
    `name` - the parameter name
  Returns:
    the parameter value,
    or `null` if it does not exist

### getInitParameterNames

    public Enumeration getInitParameterNames()

  Returns the names of this context’s initialization parameters as an enumeration, or an empty enumeration if this context has no initialization parameters.
  Returns:
    an enumeration of parameter names

### getAttribute

    public Object getAttribute(String name)

  Returns the attribute value with the given name, or `null` if no such attribute exists.

  The context attributes can be used to share information between the portlets of one portlet application.

  Parameters:
    `name` - the attribute name
  Returns:
    the attribute value

### getAttributeNames

    public Enumeration getAttributeNames()

  Returns an enumeration of the attribute names that this portlet context is aware of.
  Returns:
    an enumeration of attribute names

### include

    public void include(String path,
                        PortletRequest request,
                        PortletResponse response)
                 throws PortletException,
                        IOException

  Allows the portlet to delegate the rendering to another resource as specified by the given path. The path has to be relative and will be resolved by this method, so that the portlet's resources are accessed.
  Parameters:
    `path` - the path of the delegate resource
    `request` - the portlet request
    `response` - the portlet response
  Throws:
    `PortletException` - if the delegated resource has trouble fulfilling the rendering request
    `IOException` - if the streaming causes an I/O problem

### getResourceAsStream

    public InputStream getResourceAsStream(String path)

  Returns the resource located at the given path as an `InputStream` object.

  The data in the `InputStream` can be of any type or length. The method returns `null` if no resource exists at the given path.

  Parameters:
    `path` - the path to the resource
  Returns:
    the input stream

### getResourceAsStream

    public InputStream getResourceAsStream(String path,
                                           Locale locale)

  Returns the resource with the given locale located at the given path as an `InputStream` object.

  The data in the `InputStream` can be of any type or length. The method returns `null` if no resource exists at the given path.

  Parameters:
    `path` - the path to the resource
    `locale` - the locale to observe
  Returns:
    the input stream

### getText

    public String getText(String key,
                          Locale locale)

  Returns the localized text resource with the given key and using the given locale.

  To use this feature, the `CLASSPATH` has to contain a resource bundle with the same name (including the package) as the portlet.

  Parameters:
    `key` - the text key
    `locale` - the locale to observe
  Returns:
    the localized text resource

### send

    public void send(String aPortletName,
                     PortletMessage aMessage)

  Sends the given message to all portlets on the same page that have the given name. If the portlet name is `null` the message is broadcast to all portlets. If more than one instance of the portlet with the given name exists on the current page, the message is sent to every single instance of that portlet. If the source portlet has the same name as the target portlet(s), the message will not be sent to avoid possible cyclic calls.

  The portlet(s) with the given name will only receive the message event if it has/they have registered the appropriate listener.

  Parameters:
    `aPortletName` - the name of the portlet(s) that this
    `aMessage` - the message to be sent
  See Also:
    `addListener(org.apache.jetspeed.portlet.event.MessageListener)`

### addListener

    public void addListener(MessageListener listener)

  Adds the given message listener to this context. The listener will be called when a message is sent to this portlet by another portlet.
  Parameters:
    `listener` - the message listener to be added

### removeListener

    public void removeListener(MessageListener listener)

  Removes the given message listener from this context. Unless other message listeners remain registered with this context, the portlet will not be able to receive any more messages.
  Parameters:
    `listener` - the message listener to be removed

### getMajorVersion

    public int getMajorVersion()

  Returns the major version of the Portlet API that this portlet container supports.
  Returns:
    the major version
  See Also:
    `getMinorVersion()`

### getMinorVersion

    public int getMinorVersion()

  Returns the minor version of the Portlet API that this portlet container supports.
  Returns:
    the minor version
  See Also:
    `getMajorVersion()`

### getContainerInfo

    public String getContainerInfo()

  Returns the name and version of the portlet container which the portlet is running in.

  The form of the returned string is servername/versionnumber. For the Jetspeed Framework this method may return the string `Apache Jetspeed/1.3a1`.

  Returns:
    the string containing at least name and version number

### getLog

    public PortletLog getLog()

  Returns the portlet log which allows the portlet to write informational, warning, or error messages to a log.
  Returns:
    the portlet log

Overview | Package | Class | Tree | Deprecated | Index | Help
| Portlet API 2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD