|
Portlet API 2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
public String getInitParameter(String name)
null
if the parameter does not exist.
This method can make available configuration information useful to all portlets.
name
- the parameter namenull
if it does not existpublic Enumeration getInitParameterNames()
public Object getAttribute(String name)
null
if no such attribute exists.
The context attributes can be used to share information between the portlets of one portlet application.
name
- the attribute namepublic Enumeration getAttributeNames()
public void include(String path, PortletRequest request, PortletResponse response) throws PortletException, IOException
path
- the path of the delegate resourcerequest
- the portlet requestresponse
- the portlet responsePortletException
- if the delegated resource has trouble fulfilling the
rendering requestIOException
- if the streaming causes an I/O problempublic InputStream getResourceAsStream(String path)
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.
path
- the path to the resourcepublic InputStream getResourceAsStream(String path, Locale locale)
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.
path
- the path to the resourcelocale
- the locale to observepublic String getText(String key, Locale locale)
To use this feature, the CLASSPATH
has to contain a
resource bundle with the same name (including the package) as the
portlet.
key
- the text keylocale
- the locale to observepublic void send(String aPortletName, PortletMessage aMessage)
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.
aPortletName
- the name of the portlet(s) that thisaMessage
- the message to be sentaddListener(org.apache.jetspeed.portlet.event.MessageListener)
public void addListener(MessageListener listener)
listener
- the message listener to be addedpublic void removeListener(MessageListener listener)
listener
- the message listener to be removedpublic int getMajorVersion()
getMinorVersion()
public int getMinorVersion()
getMajorVersion()
public String getContainerInfo()
The form of the returned string is Apache Jetspeed/1.3a1
.
public PortletLog getLog()
|
Portlet API 2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |