com.vaadin.terminal.gwt.server
Class WrappedPortletResponse

java.lang.Object
  extended by com.vaadin.terminal.gwt.server.WrappedPortletResponse
All Implemented Interfaces:
WrappedResponse, Serializable

public class WrappedPortletResponse
extends Object
implements WrappedResponse

Wrapper for PortletResponse and its subclasses.

Since:
7.0
Author:
Vaadin Ltd.
See Also:
WrappedResponse, WrappedPortletRequest, Serialized Form

Constructor Summary
WrappedPortletResponse(PortletResponse response, DeploymentConfiguration deploymentConfiguration)
          Wraps a portlet response and an associated deployment configuration
 
Method Summary
 DeploymentConfiguration getDeploymentConfiguration()
          Gets the deployment configuration for the context of this response.
 OutputStream getOutputStream()
          Returns a OutputStream for writing binary data in the response.
 PortletResponse getPortletResponse()
          Gets the original, unwrapped portlet response.
 PrintWriter getWriter()
          Returns a PrintWriter object that can send character text to the client.
 void sendError(int errorCode, String message)
          Sends an error response to the client using the specified status code and clears the buffer.
 void setCacheTime(long milliseconds)
          Sets cache time in milliseconds, -1 means no cache at all.
 void setContentType(String type)
          Sets the content type of this response.
 void setDateHeader(String name, long timestamp)
          Properly formats a timestamp as a date header.
 void setHeader(String name, String value)
          Sets the value of a generic response header.
 void setStatus(int responseStatus)
          Sets the (http) status code for the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WrappedPortletResponse

public WrappedPortletResponse(PortletResponse response,
                              DeploymentConfiguration deploymentConfiguration)
Wraps a portlet response and an associated deployment configuration

Parameters:
response - the portlet response to wrap
deploymentConfiguration - the associated deployment configuration
Method Detail

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Description copied from interface: WrappedResponse
Returns a OutputStream for writing binary data in the response.

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

Specified by:
getOutputStream in interface WrappedResponse
Returns:
a OutputStream for writing binary data
Throws:
IOException - if an input or output exception occurred
See Also:
WrappedResponse.getWriter(), ServletResponse.getOutputStream(), MimeResponse#getPortletOutputStream()

getPortletResponse

public PortletResponse getPortletResponse()
Gets the original, unwrapped portlet response.

Returns:
the unwrapped portlet response

setContentType

public void setContentType(String type)
Description copied from interface: WrappedResponse
Sets the content type of this response. If the content type including a charset is set before WrappedResponse.getWriter() is invoked, the returned PrintWriter will automatically use the defined charset.

Specified by:
setContentType in interface WrappedResponse
Parameters:
type - a string specifying the MIME type of the content
See Also:
ServletResponse.setContentType(String), MimeResponse#setContentType(String)

getWriter

public PrintWriter getWriter()
                      throws IOException
Description copied from interface: WrappedResponse
Returns a PrintWriter object that can send character text to the client. The PrintWriter uses the character encoding defined using setContentType.

Either this method or getOutputStream() may be called to write the response, not both.

Specified by:
getWriter in interface WrappedResponse
Returns:
a PrintWriter for writing character text
Throws:
IOException - if an input or output exception occurred
See Also:
WrappedResponse.getOutputStream(), ServletResponse.getWriter(), MimeResponse#getWriter()

setStatus

public void setStatus(int responseStatus)
Description copied from interface: WrappedResponse
Sets the (http) status code for the response. If you want to include an error message along the status code, use WrappedResponse.sendError(int, String) instead.

Specified by:
setStatus in interface WrappedResponse
Parameters:
responseStatus - the status code to set
See Also:
HttpServletResponse.setStatus(int), ResourceResponse#HTTP_STATUS_CODE

setHeader

public void setHeader(String name,
                      String value)
Description copied from interface: WrappedResponse
Sets the value of a generic response header. If the header had already been set, the new value overwrites the previous one.

Specified by:
setHeader in interface WrappedResponse
Parameters:
name - the name of the header
value - the header value.
See Also:
HttpServletResponse.setHeader(String, String), PortletResponse#setProperty(String, String)

setDateHeader

public void setDateHeader(String name,
                          long timestamp)
Description copied from interface: WrappedResponse
Properly formats a timestamp as a date header. If the header had already been set, the new value overwrites the previous one.

Specified by:
setDateHeader in interface WrappedResponse
Parameters:
name - the name of the header
timestamp - the number of milliseconds since epoch
See Also:
HttpServletResponse.setDateHeader(String, long)

setCacheTime

public void setCacheTime(long milliseconds)
Description copied from interface: WrappedResponse
Sets cache time in milliseconds, -1 means no cache at all. All required headers related to caching in the response are set based on the time.

Specified by:
setCacheTime in interface WrappedResponse
Parameters:
milliseconds - Cache time in milliseconds

sendError

public void sendError(int errorCode,
                      String message)
               throws IOException
Description copied from interface: WrappedResponse
Sends an error response to the client using the specified status code and clears the buffer. In some configurations, this can cause a predefined error page to be displayed.

Specified by:
sendError in interface WrappedResponse
Parameters:
errorCode - the HTTP status code
message - a message to accompany the error
Throws:
IOException - if an input or output exception occurs
See Also:
HttpServletResponse.sendError(int, String)

getDeploymentConfiguration

public DeploymentConfiguration getDeploymentConfiguration()
Description copied from interface: WrappedResponse
Gets the deployment configuration for the context of this response.

Specified by:
getDeploymentConfiguration in interface WrappedResponse
Returns:
the deployment configuration
See Also:
DeploymentConfiguration


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.