public interface PortletResponse
PortletResponse
defines the base interface to assist a
portlet in creating and sending a response to the client. The portlet
container uses specialized versions of this interface when invoking a
portlet.
The portlet container creates these objects and passes them as arguments to
the portlet's processAction, processEvent, serveResource
and render
methods.ActionResponse
,
RenderResponse
,
EventResponse
,
ResourceResponse
Modifier and Type | Method and Description |
---|---|
void |
addProperty(javax.servlet.http.Cookie cookie)
Adds a HTTP Cookie property to the response.
The portlet should note that the cookie may not make it to the client, but may be stored at the portal. |
void |
addProperty(String key,
Element element)
Adds an XML DOM element property to the response.
|
void |
addProperty(String key,
String value)
Adds a String property to an existing key to be returned to the portal.
|
Element |
createElement(String tagName)
Creates an element of the type specified to be used in the
addProperty(String,Element) method. |
String |
encodeURL(String path)
Returns the encoded URL of the resource, like servlets, JSPs, images and
other static files, at the given path.
|
String |
getNamespace()
The value returned by this method should be prefixed or appended to
elements, such as JavaScript variables or function names, to ensure they
are unique in the context of the portal page.
|
String |
getProperty(String key)
Gets the value of the response property with the given name.
|
Collection<String> |
getPropertyNames()
Gets the names of all response properties set on the response.
|
Collection<String> |
getPropertyValues(String key)
Gets the values of the response property with the given name.
|
void |
setProperty(String key,
String value)
Sets a String property to be returned to the portal.
|
void addProperty(String key, String value)
This method allows response properties to have multiple values.
Response properties can be viewed as header values set for the portal application. If these header values are intended to be transmitted to the client they should be set before the response is committed.
key
- the key of the property to be returned to the portalvalue
- the value of the property to be returned to the portal.
The value should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt).
IllegalArgumentException
- if key is null
.void setProperty(String key, String value)
Response properties can be viewed as header values set for the portal application. If these header values are intended to be transmitted to the client they should be set before the response is committed.
This method resets all properties previously added with the same key.
key
- the key of the property to be returned to the portalvalue
- the value of the property to be returned to the portal.
The value should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt).
IllegalArgumentException
- if key is null
.String encodeURL(String path)
Portlets should encode all resource URLs pointing to resources in the portlet application via this method in order to ensure that they get served via the portal application.
Some portal/portlet-container implementation may require those URLs to contain implementation specific data encoded in it. Because of that, portlets should use this method to create such URLs.
The encodeURL
method may include the session ID and other
portal/portlet-container specific information into the URL. If encoding
is not needed, it returns the URL unchanged.
Portlet developer should be aware that the returned URL might not be a well formed URL but a special token at the time the portlet is generating its content. Thus portlets should not add additional parameters on the resulting URL or expect to be able to parse the URL. As a result, the outcome of the encodeURL call may be different than calling encodeURL in the servlet world.
path
- the URI path to the resource. This must be either an absolute
URL (e.g.
http://my.co/myportal/mywebap/myfolder/myresource.gif
)
or a full path URI (e.g.
/myportal/mywebap/myfolder/myresource.gif
).IllegalArgumentException
- if path doesn't have a leading slash or is not an absolute
URLString getNamespace()
The namespace value must be constant for the lifetime of the portlet window.
void addProperty(javax.servlet.http.Cookie cookie)
This method allows response properties to have multiple cookies.
cookie
- the cookie to be added to the responseIllegalArgumentException
- if cookie is null
.void addProperty(String key, Element element)
If a DOM element with the provided key already exists the provided element will be stored in addition to the existing element under the same key.
If the element is null
the key is removed from
the response.
Response XML DOM element properties can be viewed as additional response document sections set for the portal application. If these header values are intended to be transmitted to the client they should be set before the response is committed.
key
- the key of the property to be returned to the portalelement
- the XML DOM element to be added to the responseIllegalArgumentException
- if key is null
.Element createElement(String tagName) throws DOMException
addProperty(String,Element)
method.tagName
- name of the element type to instantiateDOMException
- INVALID_CHARACTER_ERR: Raised if the specified name
contains an illegal character.String getProperty(String key)
If a response property with the given name exists and contains multiple values, the value that was added first will be returned.
This method considers only response properties set or added via
setProperty(java.lang.String, java.lang.String)
or
addProperty(java.lang.String, java.lang.String)
.
key
- the name of the response property whose value is to be returnedCollection<String> getPropertyValues(String key)
This method considers only response properties set or added via
setProperty(java.lang.String, java.lang.String)
or
addProperty(java.lang.String, java.lang.String)
.
Altering the returned collection will not affect the properties set on the response.
key
- the name of the response property whose values are to be returnedCollection<String> getPropertyNames()
This method considers only response properties set or added via
setProperty(java.lang.String, java.lang.String)
or
addProperty(java.lang.String, java.lang.String)
.
Altering the returned collection will not affect the properties set on the response.
Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.