com.vaadin.server
Class VaadinPortletResponse

java.lang.Object
  extended by com.vaadin.server.VaadinPortletResponse
All Implemented Interfaces:
VaadinResponse, java.io.Serializable

public class VaadinPortletResponse
extends java.lang.Object
implements VaadinResponse

Wrapper for PortletResponse and its subclasses.

Since:
7.0
Author:
Vaadin Ltd.
See Also:
VaadinResponse, VaadinPortletRequest, Serialized Form

Constructor Summary
VaadinPortletResponse(javax.portlet.PortletResponse response, VaadinPortletService vaadinService)
          Wraps a portlet response and an associated vaadin service
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds the specified cookie to the response.
 java.io.OutputStream getOutputStream()
          Returns a OutputStream for writing binary data in the response.
 javax.portlet.PortletResponse getPortletResponse()
          Gets the original, unwrapped portlet response.
 VaadinPortletService getService()
          Gets the vaadin service for the context of this response.
 java.io.PrintWriter getWriter()
          Returns a PrintWriter object that can send character text to the client.
 void sendError(int errorCode, java.lang.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(java.lang.String type)
          Sets the content type of this response.
 void setDateHeader(java.lang.String name, long timestamp)
          Properly formats a timestamp as a date header.
 void setHeader(java.lang.String name, java.lang.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

VaadinPortletResponse

public VaadinPortletResponse(javax.portlet.PortletResponse response,
                             VaadinPortletService vaadinService)
Wraps a portlet response and an associated vaadin service

Parameters:
response - the portlet response to wrap
vaadinService - the associated vaadin service
Method Detail

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Description copied from interface: VaadinResponse
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 VaadinResponse
Returns:
a OutputStream for writing binary data
Throws:
java.io.IOException - if an input or output exception occurred
See Also:
VaadinResponse.getWriter(), ServletResponse.getOutputStream(), MimeResponse.getPortletOutputStream()

getPortletResponse

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

Returns:
the unwrapped portlet response

setContentType

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

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

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Description copied from interface: VaadinResponse
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 VaadinResponse
Returns:
a PrintWriter for writing character text
Throws:
java.io.IOException - if an input or output exception occurred
See Also:
VaadinResponse.getOutputStream(), ServletResponse.getWriter(), MimeResponse.getWriter()

setStatus

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

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

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Description copied from interface: VaadinResponse
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 VaadinResponse
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(java.lang.String name,
                          long timestamp)
Description copied from interface: VaadinResponse
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 VaadinResponse
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: VaadinResponse
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 VaadinResponse
Parameters:
milliseconds - Cache time in milliseconds

sendError

public void sendError(int errorCode,
                      java.lang.String message)
               throws java.io.IOException
Description copied from interface: VaadinResponse
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 VaadinResponse
Parameters:
errorCode - the HTTP status code
message - a message to accompany the error
Throws:
java.io.IOException - if an input or output exception occurs
See Also:
HttpServletResponse.sendError(int, String)

getService

public VaadinPortletService getService()
Description copied from interface: VaadinResponse
Gets the vaadin service for the context of this response.

Specified by:
getService in interface VaadinResponse
Returns:
the vaadin service
See Also:
VaadinService

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Description copied from interface: VaadinResponse
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

Specified by:
addCookie in interface VaadinResponse
Parameters:
cookie - the Cookie to return to the client
See Also:
HttpServletResponse.addCookie(Cookie), PortletResponse.addProperty(Cookie)


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