|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | 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 | |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the attribute value with the given name, or null
if no such attribute exists.
|
java.util.Enumeration |
getAttributeNames()
Returns an enumeration of the attribute names that this portlet context is aware of. |
java.lang.String |
getContainerInfo()
Returns the name and version of the portlet container which the portlet is running in. |
java.lang.String |
getInitParameter(java.lang.String name)
Returns the value of the context-wide initialization parameter with the given name, or null if the parameter does not exist.
|
java.util.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. |
java.io.InputStream |
getResourceAsStream(java.lang.String path)
Returns the resource located at the given path as an InputStream object.
|
java.lang.String |
getText(java.lang.String key,
java.lang.String bundleName,
java.util.Locale locale)
Returns the localized text resource with the given key and using the given locale. |
void |
include(java.lang.String path,
PortletRequest request,
PortletResponse response)
Allows the portlet to delegate the rendering to another resource as specified by the given path. |
void |
removeAttribute(java.lang.String name)
Removes the attribute with the given name. |
void |
send(java.lang.String aPortletName,
PortletMessage aMessage)
Sends the given message to all portlets on the same page that have the given name. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Associates an attribute with the given name and value with this context. |
Method Detail |
public java.lang.String getInitParameter(java.lang.String name)
null
if the parameter does not exist.
This method can make available configuration information useful to all portlets.
name
- the parameter name
null
if it does not existpublic java.util.Enumeration getInitParameterNames()
public void setAttribute(java.lang.String name, java.lang.Object value)
name
- the attribute namevalue
- the attribute valuepublic java.lang.Object getAttribute(java.lang.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 name
public java.util.Enumeration getAttributeNames()
public void removeAttribute(java.lang.String name)
name
- the name of attribute to be removedpublic void include(java.lang.String path, PortletRequest request, PortletResponse response) throws PortletException, java.io.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.
To access protected resources the path has to be prefixed with /portlet-inf/ (e.g. /portlet-inf/myportlet/myportlet.jsp). Otherwise, the direct path is used. (e.g. /myportlet/myportlet.jsp).
This method is enabled for multi-language and multi-device support. For example, a jsp file "/myportlet/mytemplate.jsp" will be searched for in the following order, when accessing via HTML-Browser: 1. /html/en/US/IE/mytemplate.jsp 2. /html/en/US/mytemplate.jsp 3. /html/en/mytemplate.jsp 4. /html/mytemplate.jsp 5. /en/US/IE/mytemplate.jsp 6. /en/US/mytemplate.jsp 7. /en/mytemplate.jsp 8. /mytemplate.jsp
path
- the path of the delegate resourcerequest
- the portlet requestresponse
- the portlet response
PortletException
- if the delegated resource has trouble fulfilling the
rendering request
java.io.IOException
- if the streaming causes an I/O problempublic java.io.InputStream getResourceAsStream(java.lang.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.
To access protected resources the path has to be prefixed with /portlet-inf/ (e.g. /portlet-inf/myportlet/myportlet.jsp). Otherwise, the direct path is used. (e.g. /myportlet/myportlet.jsp).
path
- the path to the resource
public java.lang.String getText(java.lang.String key, java.lang.String bundleName, java.util.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 keybundleName
- the name of the resource bundlelocale
- the locale to observe
public void send(java.lang.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. This is done by registering the listener in the portlet descriptor.
aPortletName
- the name of the portlet(s) that thisaMessage
- the message to be sentpublic int getMajorVersion()
getMinorVersion()
public int getMinorVersion()
getMajorVersion()
public java.lang.String getContainerInfo()
The form of the returned string is Apache Jetspeed/1.3a1
.
public PortletLog getLog()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |