javax.portlet
Interface PortletResponse

All Known Subinterfaces:
ActionResponse, EventResponse, MimeResponse, RenderResponse, ResourceResponse, StateAwareResponse
All Known Implementing Classes:
ActionResponseWrapper, EventResponseWrapper, PortletResponseWrapper, RenderResponseWrapper, ResourceResponseWrapper

public interface PortletResponse

The 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.

See Also:
ActionResponse, RenderResponse, EventResponse, ResourceResponse

Method Summary
 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(java.lang.String key, org.w3c.dom.Element element)
          Adds an XML DOM element property to the response.
 void addProperty(java.lang.String key, java.lang.String value)
          Adds a String property to an existing key to be returned to the portal.
 org.w3c.dom.Element createElement(java.lang.String tagName)
          Creates an element of the type specified to be used in the addProperty(String,Element) method.
 java.lang.String encodeURL(java.lang.String path)
          Returns the encoded URL of the resource, like servlets, JSPs, images and other static files, at the given path.
 java.lang.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.
 void setProperty(java.lang.String key, java.lang.String value)
          Sets a String property to be returned to the portal.
 

Method Detail

addProperty

void addProperty(java.lang.String key,
                 java.lang.String value)
Adds a String property to an existing key to be returned to the portal. If there are no property values already associated with the key, a new key is created.

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.

Parameters:
key - the key of the property to be returned to the portal
value - the value of the property to be returned to the portal
Throws:
java.lang.IllegalArgumentException - if key is null.

setProperty

void setProperty(java.lang.String key,
                 java.lang.String value)
Sets a String property to be returned to the portal.

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.

Parameters:
key - the key of the property to be returned to the portal
value - the value of the property to be returned to the portal
Throws:
java.lang.IllegalArgumentException - if key is null.

encodeURL

java.lang.String encodeURL(java.lang.String path)
Returns the encoded URL of the resource, like servlets, JSPs, images and other static files, at the given 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.

Parameters:
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).
Returns:
the encoded resource URL as string, may not be a valid URL
Throws:
java.lang.IllegalArgumentException - if path doesn't have a leading slash or is not an absolute URL

getNamespace

java.lang.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.

The namespace value must be constant for the lifetime of the portlet window.

Returns:
the namespace

addProperty

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.

This method allows response properties to have multiple cookies.

Parameters:
cookie - the cookie to be added to the response
Throws:
java.lang.IllegalArgumentException - if cookie is null.
Since:
2.0

addProperty

void addProperty(java.lang.String key,
                 org.w3c.dom.Element element)
Adds an XML DOM element property to the response.

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.

Parameters:
key - the key of the property to be returned to the portal
element - the XML DOM element to be added to the response
Throws:
java.lang.IllegalArgumentException - if key is null.
Since:
2.0

createElement

org.w3c.dom.Element createElement(java.lang.String tagName)
                                  throws org.w3c.dom.DOMException
Creates an element of the type specified to be used in the addProperty(String,Element) method.

Parameters:
tagName - name of the element type to instantiate
Returns:
A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.