Overview Package Class Tree Serialized Deprecated Index Help PREV class NEXT class SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
org.apache.jetspeed.portlet
Interface PortletContext
- All Superinterfaces:
- javax.servlet.ServletContext
- public interface PortletContext
- extends javax.servlet.ServletContext
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.
- Since:
- 4.1
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 contexts 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 debug, 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.io.InputStream java.util.Locale)">getResourceAsStream(java.lang.String path, Client client, java.util.Locale locale)
Returns the resource located at the given path as an InputStream object.PortletService getService(java.lang.Class service)
This function looks up a portlet service with the given classname.java.lang.String java.util.Locale)">getText(java.lang.String bundle, java.lang.String key, 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 portletName, DefaultPortletMessage message)
Sends the given message to all portlets on the same page that have the given name regardless of the portlet application.void send(java.lang.String portletName, PortletMessage message)
Sends the given message to all portlets in the same portlet application on the same page that have the given name.void send(java.lang.String portletName, PortletMessage message, PortletRequest request)
Deprecated. since V1.1void setAttribute(java.lang.String name, java.lang.Object value)
Associates an attribute with the given name and value with this context.
Methods inherited from interface javax.servlet.ServletContext getContext, getMimeType, getNamedDispatcher, getRealPath, getRequestDispatcher, getResource, getResourcePaths, getServerInfo, getServlet, getServletContextName, getServletNames, getServlets, log, log, log
Method Detail getInitParameter
public 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.
This method can make available configuration information useful to all portlets. The configuration is read from the portlet deployment descriptor.
- Specified by:
- getInitParameter in interface javax.servlet.ServletContext
- Parameters:
- name - the parameter name
- Returns:
- the parameter value,
or null if it does not exist
getInitParameterNames
public java.util.Enumeration getInitParameterNames()
- Returns the names of this contexts initialization parameters as an enumeration, or an empty enumeration if this context has no initialization parameters.
The configuration is read from the portlet deployment descriptor.
- Specified by:
- getInitParameterNames in interface javax.servlet.ServletContext
- Returns:
- an enumeration of parameter names
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
- Associates an attribute with the given name and value with this context. If a portlet needs to communicate information to embedded servlets or JSP, this methods can used carry the information along.
- Specified by:
- setAttribute in interface javax.servlet.ServletContext
- Parameters:
- name - the attribute name
- value - the attribute value
getAttribute
public java.lang.Object getAttribute(java.lang.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.
- Specified by:
- getAttribute in interface javax.servlet.ServletContext
- Parameters:
- name - the attribute name
- Returns:
- the attribute value
getAttributeNames
public java.util.Enumeration getAttributeNames()
- Returns an enumeration of the attribute names that this portlet context is aware of.
- Specified by:
- getAttributeNames in interface javax.servlet.ServletContext
- Returns:
- an enumeration of attribute names
removeAttribute
public void removeAttribute(java.lang.String name)
- Removes the attribute with the given name.
- Specified by:
- removeAttribute in interface javax.servlet.ServletContext
- Parameters:
- name - the name of attribute to be removed
include
public void include(java.lang.String path, PortletRequest request, PortletResponse response) throws org.apache.jetspeed.portlet.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 /WEB-INF/ (e.g. /WEB-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:
- /myportlet/html/en_US/mytemplate.jsp
- /myportlet/html/en/mytemplate.jsp
- /myportlet/html/mytemplate.jsp
- /myportlet/mytemplate.jsp
- 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
- java.io.IOException - if the streaming causes an I/O problem
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.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.
To access protected resources the path has to be prefixed with /WEB-INF/ (e.g. /WEB-INF/myportlet/myportlet.jsp). Otherwise, the direct path is used. (e.g. /myportlet/myportlet.jsp).
- Specified by:
- getResourceAsStream in interface javax.servlet.ServletContext
- Parameters:
- path - the path to the resource
- Returns:
- the input stream
java.util.Locale)">getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String path, Client client, java.util.Locale locale)
- 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.
To access protected resources the path has to be prefixed with /WEB-INF/ (e.g. /WEB-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:
- /myportlet/html/en_US/mytemplate.jsp
- /myportlet/html/en/mytemplate.jsp
- /myportlet/html/mytemplate.jsp
- /myportlet/mytemplate.jsp
- Parameters:
- path - the path to the resource
- client - the client
- locale - the locale
- Returns:
- the input stream
java.util.Locale)">getText
public java.lang.String getText(java.lang.String bundle, java.lang.String key, java.util.Locale locale)
- Returns the localized text resource with the given key and using the given locale.
To use this feature, the portlet application's classPATH has to contain a resource bundle with the same name (including the package) as the portlet.
- Parameters:
- bundle - the name of the resource bundle
- key - the text key
- locale - the locale to observe
- Returns:
- the localized text resource
send
public void send(java.lang.String portletName, PortletMessage message, PortletRequest request) throws AccessDeniedException
- Deprecated. since V1.1
- Sends the given message to all portlets in the same portlet application on the same page that have the given name. If the portlet name is null the message is broadcast to all portlets in the same portlet application. 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 implemented the appropriate listener.
This function may only be used during event processing, in any other case the method throws an AccessDeniedException.
- Parameters:
- portletName - the name of the portlet(s) that this
- message - the message to be sent
- request - the portlet request
- Throws:
- AccessDeniedException - if the portlet tries to access this function outside of the event processing
send
public void send(java.lang.String portletName, PortletMessage message) throws AccessDeniedException
- Sends the given message to all portlets in the same portlet application on the same page that have the given name. If the portlet name is null the message is broadcast to all portlets in the same portlet application. 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 implemented the appropriate listener.
This function may only be used during event processing, in any other case the method throws an AccessDeniedException.
- Parameters:
- portletName - the name of the portlet(s) that this
- message - the message to be sent
- Throws:
- AccessDeniedException - if the portlet tries to access this function outside of the event processing
send
public void send(java.lang.String portletName, DefaultPortletMessage message) throws AccessDeniedException
- Sends the given message to all portlets on the same page that have the given name regardless of the portlet application. If the portlet name is null the message is broadcast to all portlets on the same page across all portlet application. 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 implemented the appropriate listener.
This function may only be used during event processing, in any other case the method throws an AccessDeniedException.
- Parameters:
- portletName - the name of the portlet(s) that this
- message - the message to be sent
- Throws:
- AccessDeniedException - if the portlet tries to access this function outside of the event processing
getService
public PortletService getService(java.lang.Class service) throws PortletServiceUnavailableException, PortletServiceNotFoundException
- This function looks up a portlet service with the given classname.
Using this method a portlet is able to get additional functionality like a service to get external content over a firewall or to include a servlet.
- Parameters:
- service - the classname of the service to load
- Returns:
- the portlet service
- Throws:
- PortletServiceUnavailableException - if an exception has occurrred that interferes with the portlet service's normal initialization
- PortletServiceNotFoundException - if the PortletService is not found
getMajorVersion
public int getMajorVersion()
- Returns the major version of the Portlet API that this portlet container supports.
- Specified by:
- getMajorVin interface javax.servlet.ServletContext
- Returns:
- the major version
- See Also:
- getMinorVersion()
getMinorVersion
public int getMinorVersion()
- Returns the minor version of the Portlet API that this portlet container supports.
- Specified by:
- getMinorVin interface javax.servlet.ServletContext
- Returns:
- the minor version
- See Also:
- getMajorVersion()
getContainerInfo
public java.lang.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 IBM Portal Server this method may return the string IBM WebSphere Portal Server/4.1.
- Returns:
- the string containing at least name and version number
getLog
public PortletLog getLog()
- Returns the portlet log which allows the portlet to write debug, informational, warning, or error messages to a log.
- Returns:
- the portlet log
Overview Package Class Tree Serialized Deprecated Index Help PREV class NEXT class SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.
IBM is a trademark of the IBM Corporation in the United States, other countries, or both.