org.apache.pluto.wrappers
Class RenderResponseWrapper

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by javax.servlet.http.HttpServletResponseWrapper
          extended by org.apache.pluto.wrappers.PortletResponseWrapper
              extended by org.apache.pluto.wrappers.RenderResponseWrapper
All Implemented Interfaces:
MimeResponse, PortletResponse, RenderResponse, javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse

public class RenderResponseWrapper
extends PortletResponseWrapper
implements RenderResponse


Field Summary
 
Fields inherited from interface javax.portlet.MimeResponse
CACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT
 
Fields inherited from interface javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
 
Constructor Summary
RenderResponseWrapper(RenderResponse renderResponse)
          Creates a ServletResponse adaptor wrapping the given response object.
 
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.
 PortletURL createActionURL()
          Creates a portlet URL targeting the portlet.
 PortletURL createRenderURL()
          Creates a portlet URL targeting the portlet.
 void flushBuffer()
          Forces any content in the buffer to be written to the underlying output stream.
 int getBufferSize()
          Returns the actual buffer size used for the response.
 CacheControl getCacheControl()
          Returns an implementation of JSR-286 CacheContol.
 java.lang.String getCharacterEncoding()
          Returns the name of the charset used for the MIME body sent in this response.
 java.lang.String getContentType()
          Returns the MIME type that can be used to contribute markup to the render response.
 java.util.Locale getLocale()
          Returns the locale assigned to the response.
 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.
 java.io.OutputStream getPortletOutputStream()
          Returns a OutputStream suitable for writing binary data in the response.
 RenderResponse getRenderResponse()
          Return the wrapped ServletResponse object.
 java.io.PrintWriter getWriter()
          Returns a PrintWriter object that can send character text to the portal.
 boolean isCommitted()
          Returns a boolean indicating if the response has been committed.
 void reset()
          Clears any data that exists in the buffer as well as the properties set.
 void resetBuffer()
          Clears the content of the underlying buffer in the response without clearing properties set.
 void setBufferSize(int size)
          Sets the preferred buffer size for the body of the response.
 void setContentType(java.lang.String type)
          Sets the MIME type for the render response.
 void setNextPossiblePortletModes(java.util.Collection<PortletMode> portletModes)
          This method allows the portlet to tell the portal the next possible portlet modes that the make sense from the portlet point of view.
 void setTitle(java.lang.String title)
          This method sets the title of the portlet.
 
Methods inherited from class org.apache.pluto.wrappers.PortletResponseWrapper
addProperty, addProperty, createElement, createResourceURL, encodeURL, getPortletResponse, setProperty, setResponse
 
Methods inherited from class javax.servlet.http.HttpServletResponseWrapper
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setStatus
 
Methods inherited from class javax.servlet.ServletResponseWrapper
getOutputStream, getResponse, setCharacterEncoding, setContentLength, setLocale, setResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.portlet.MimeResponse
createResourceURL
 
Methods inherited from interface javax.portlet.PortletResponse
addProperty, addProperty, createElement, encodeURL, setProperty
 
Methods inherited from interface javax.servlet.ServletResponse
getOutputStream, setCharacterEncoding, setContentLength, setLocale
 

Constructor Detail

RenderResponseWrapper

public RenderResponseWrapper(RenderResponse renderResponse)
Creates a ServletResponse adaptor wrapping the given response object.

Throws:
java.lang.IllegalArgumentException - if the response is null.
Method Detail

getContentType

public java.lang.String getContentType()
Description copied from interface: MimeResponse
Returns the MIME type that can be used to contribute markup to the render response.

If no content type was set previously using the MimeResponse.setContentType(java.lang.String) method this method returns null.

Specified by:
getContentType in interface MimeResponse
Specified by:
getContentType in interface javax.servlet.ServletResponse
Overrides:
getContentType in class javax.servlet.ServletResponseWrapper
Returns:
the MIME type of the response, or null if no content type is set
See Also:
MimeResponse.setContentType(java.lang.String)

createRenderURL

public PortletURL createRenderURL()
Description copied from interface: MimeResponse
Creates a portlet URL targeting the portlet. If no portlet mode, window state or security modifier is set in the PortletURL the current values are preserved. If a request is triggered by the PortletURL, it results in a render request.

The returned URL can be further extended by adding portlet-specific parameters and portlet modes and window states.

The created URL will per default not contain any parameters of the current render request.

Specified by:
createRenderURL in interface MimeResponse
Overrides:
createRenderURL in class PortletResponseWrapper
Returns:
a portlet render URL

createActionURL

public PortletURL createActionURL()
Description copied from interface: MimeResponse
Creates a portlet URL targeting the portlet. If no portlet mode, window state or security modifier is set in the PortletURL the current values are preserved. If a request is triggered by the PortletURL, it results in an action request.

The returned URL can be further extended by adding portlet-specific parameters and portlet modes and window states.

The created URL will per default not contain any parameters of the current render request.

Specified by:
createActionURL in interface MimeResponse
Overrides:
createActionURL in class PortletResponseWrapper
Returns:
a portlet action URL

getNamespace

public java.lang.String getNamespace()
Description copied from interface: PortletResponse
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.

Specified by:
getNamespace in interface PortletResponse
Overrides:
getNamespace in class PortletResponseWrapper
Returns:
the namespace

setTitle

public void setTitle(java.lang.String title)
Description copied from interface: RenderResponse
This method sets the title of the portlet.

The value can be a text String

Specified by:
setTitle in interface RenderResponse
Parameters:
title - portlet title as text String or resource URI

setContentType

public void setContentType(java.lang.String type)
Description copied from interface: MimeResponse
Sets the MIME type for the render response. The portlet must set the content type before calling MimeResponse.getWriter() or MimeResponse.getPortletOutputStream().

Calling setContentType after getWriter or getOutputStream does not change the content type.

The portlet container will ignore any character encoding specified as part of the content type for render calls.

Specified by:
setContentType in interface MimeResponse
Specified by:
setContentType in interface javax.servlet.ServletResponse
Overrides:
setContentType in class javax.servlet.ServletResponseWrapper
Parameters:
type - the content MIME type
See Also:
PortletRequest.getResponseContentTypes(), MimeResponse.getContentType()

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Description copied from interface: MimeResponse
Returns the name of the charset used for the MIME body sent in this response.

See RFC 2047 for more information about character encoding and MIME.

Specified by:
getCharacterEncoding in interface MimeResponse
Specified by:
getCharacterEncoding in interface javax.servlet.ServletResponse
Overrides:
getCharacterEncoding in class javax.servlet.ServletResponseWrapper
Returns:
a String specifying the name of the charset, for example, ISO-8859-1

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Description copied from interface: MimeResponse
Returns a PrintWriter object that can send character text to the portal.

Before calling this method the content type of the render response must be set using the MimeResponse.setContentType(java.lang.String) method.

Either this method or MimeResponse.getPortletOutputStream() may be called to write the body, not both.

Specified by:
getWriter in interface MimeResponse
Specified by:
getWriter in interface javax.servlet.ServletResponse
Overrides:
getWriter in class javax.servlet.ServletResponseWrapper
Returns:
a PrintWriter object that can return character data to the portal
Throws:
java.io.IOException - if an input or output exception occurred
See Also:
MimeResponse.setContentType(java.lang.String), MimeResponse.getPortletOutputStream()

getLocale

public java.util.Locale getLocale()
Description copied from interface: MimeResponse
Returns the locale assigned to the response.

Specified by:
getLocale in interface MimeResponse
Specified by:
getLocale in interface javax.servlet.ServletResponse
Overrides:
getLocale in class javax.servlet.ServletResponseWrapper
Returns:
Locale of this response

setBufferSize

public void setBufferSize(int size)
Description copied from interface: MimeResponse
Sets the preferred buffer size for the body of the response. The portlet container will use a buffer at least as large as the size requested.

This method must be called before any response body content is written; if content has been written, or the portlet container does not support buffering, this method may throw an IllegalStateException.

Specified by:
setBufferSize in interface MimeResponse
Specified by:
setBufferSize in interface javax.servlet.ServletResponse
Overrides:
setBufferSize in class javax.servlet.ServletResponseWrapper
Parameters:
size - the preferred buffer size
See Also:
MimeResponse.getBufferSize(), MimeResponse.flushBuffer(), MimeResponse.isCommitted(), MimeResponse.reset()

getBufferSize

public int getBufferSize()
Description copied from interface: MimeResponse
Returns the actual buffer size used for the response. If no buffering is used, this method returns 0.

Specified by:
getBufferSize in interface MimeResponse
Specified by:
getBufferSize in interface javax.servlet.ServletResponse
Overrides:
getBufferSize in class javax.servlet.ServletResponseWrapper
Returns:
the actual buffer size used
See Also:
MimeResponse.setBufferSize(int), MimeResponse.flushBuffer(), MimeResponse.isCommitted(), MimeResponse.reset()

flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Description copied from interface: MimeResponse
Forces any content in the buffer to be written to the underlying output stream. A call to this method automatically commits the response.

Specified by:
flushBuffer in interface MimeResponse
Specified by:
flushBuffer in interface javax.servlet.ServletResponse
Overrides:
flushBuffer in class javax.servlet.ServletResponseWrapper
Throws:
java.io.IOException - if an error occurred when writing the output
See Also:
MimeResponse.setBufferSize(int), MimeResponse.getBufferSize(), MimeResponse.isCommitted(), MimeResponse.reset()

resetBuffer

public void resetBuffer()
Description copied from interface: MimeResponse
Clears the content of the underlying buffer in the response without clearing properties set. If the response has been committed, this method throws an IllegalStateException.

Specified by:
resetBuffer in interface MimeResponse
Specified by:
resetBuffer in interface javax.servlet.ServletResponse
Overrides:
resetBuffer in class javax.servlet.ServletResponseWrapper
See Also:
MimeResponse.setBufferSize(int), MimeResponse.getBufferSize(), MimeResponse.isCommitted(), MimeResponse.reset()

isCommitted

public boolean isCommitted()
Description copied from interface: MimeResponse
Returns a boolean indicating if the response has been committed.

Specified by:
isCommitted in interface MimeResponse
Specified by:
isCommitted in interface javax.servlet.ServletResponse
Overrides:
isCommitted in class javax.servlet.ServletResponseWrapper
Returns:
a boolean indicating if the response has been committed
See Also:
MimeResponse.setBufferSize(int), MimeResponse.getBufferSize(), MimeResponse.flushBuffer(), MimeResponse.reset()

reset

public void reset()
Description copied from interface: MimeResponse
Clears any data that exists in the buffer as well as the properties set. If the response has been committed, this method throws an IllegalStateException.

Specified by:
reset in interface MimeResponse
Specified by:
reset in interface javax.servlet.ServletResponse
Overrides:
reset in class javax.servlet.ServletResponseWrapper
See Also:
MimeResponse.setBufferSize(int), MimeResponse.getBufferSize(), MimeResponse.flushBuffer(), MimeResponse.isCommitted()

getPortletOutputStream

public java.io.OutputStream getPortletOutputStream()
                                            throws java.io.IOException
Description copied from interface: MimeResponse
Returns a OutputStream suitable for writing binary data in the response. The portlet container does not encode the binary data.

Before calling this method the content type of the render response must be set using the MimeResponse.setContentType(java.lang.String) method.

Calling flush() on the OutputStream commits the response.

Either this method or MimeResponse.getWriter() may be called to write the body, not both.

Specified by:
getPortletOutputStream in interface MimeResponse
Returns:
a OutputStream for writing binary data
Throws:
java.io.IOException - if an input or output exception occurred
See Also:
MimeResponse.setContentType(java.lang.String), MimeResponse.getWriter()

getCacheControl

public CacheControl getCacheControl()
Returns an implementation of JSR-286 CacheContol.

Specified by:
getCacheControl in interface MimeResponse
Returns:
Cache control for the current response.
Since:
2.0

getRenderResponse

public RenderResponse getRenderResponse()
Return the wrapped ServletResponse object.


addProperty

public void addProperty(javax.servlet.http.Cookie cookie)
Description copied from interface: MimeResponse
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.

Specified by:
addProperty in interface MimeResponse
Parameters:
cookie - the cookie to be added to the response

setNextPossiblePortletModes

public void setNextPossiblePortletModes(java.util.Collection<PortletMode> portletModes)
Description copied from interface: RenderResponse
This method allows the portlet to tell the portal the next possible portlet modes that the make sense from the portlet point of view.

If set, the portal should honor these enumeration of portlet modes and only provide the end user with choices to the provided portlet modes or a subset of these modes based on access control considerations.

If the portlet does not set any next possible portlet modes the default is that all portlet modes that the portlet has defined supporting in the portlet deployment descriptor are meaningful new portlet modes.

Specified by:
setNextPossiblePortletModes in interface RenderResponse
Parameters:
portletModes - Enumeration of PortletMode objects with the next possible portlet modes that the make sense from the portlet point of view, must not be null or an empty enumeration.


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.