com.vaadin.server.
Class VaadinPortletResponse
- java.lang.Object
-
- com.vaadin.server.VaadinPortletResponse
-
All Implemented Interfaces:
public class VaadinPortletResponse extends Object implements VaadinResponse
Wrapper for
PortletResponse
and its subclasses.Since:
7.0
Author:
Vaadin Ltd.
See Also:
-
-
Constructor Summary
Constructors Constructor and Description VaadinPortletResponse(PortletResponse response, VaadinPortletService vaadinService)
Wraps a portlet response and an associated vaadin service
-
Method Summary
All Methods Modifier and Type Method and Description void
addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response.
OutputStream
getOutputStream()
Returns a
OutputStream
for writing binary data in the response.PortletResponse
getPortletResponse()
Gets the original, unwrapped portlet response.
VaadinPortletService
getService()
Gets the vaadin service for the context of this 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
setContentLength(int len)
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.
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.
-
-
-
Constructor Detail
-
VaadinPortletResponse
public VaadinPortletResponse(PortletResponse response, VaadinPortletService vaadinService)
Wraps a portlet response and an associated vaadin service
Parameters:
response
- the portlet response to wrapvaadinService
- the associated vaadin service
-
-
Method Detail
-
getOutputStream
public OutputStream getOutputStream() throws 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 interfaceVaadinResponse
Returns:
a
OutputStream
for writing binary dataThrows:
IOException
- if an input or output exception occurredSee Also:
VaadinResponse.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:
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 interfaceVaadinResponse
Parameters:
type
- a string specifying the MIME type of the contentSee Also:
ServletResponse.setContentType(String)
,MimeResponse#setContentType(String)
-
setContentLength
public void setContentLength(int len)
Description copied from interface:
VaadinResponse
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header. For some portlet responses, this method sets the content-length header, for others this method does nothing.
Specified by:
setContentLength
in interfaceVaadinResponse
Parameters:
len
- an integer specifying the length of the content being returned to the client
-
getWriter
public PrintWriter getWriter() throws 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 interfaceVaadinResponse
Returns:
a
PrintWriter
for writing character textThrows:
IOException
- if an input or output exception occurredSee 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 interfaceVaadinResponse
Parameters:
responseStatus
- the status code to setSee Also:
HttpServletResponse.setStatus(int)
,ResourceResponse#HTTP_STATUS_CODE
-
setHeader
public void setHeader(String name, 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 interfaceVaadinResponse
Parameters:
name
- the name of the headervalue
- 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:
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 interfaceVaadinResponse
Parameters:
name
- the name of the headertimestamp
- the number of milliseconds since epochSee 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 interfaceVaadinResponse
Parameters:
milliseconds
- Cache time in milliseconds
-
sendError
public void sendError(int errorCode, String message) throws 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 interfaceVaadinResponse
Parameters:
errorCode
- the HTTP status codemessage
- a message to accompany the errorThrows:
IOException
- if an input or output exception occursSee 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 interfaceVaadinResponse
Returns:
the vaadin service
See Also:
-
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 interfaceVaadinResponse
Parameters:
cookie
- the Cookie to return to the clientSee Also:
HttpServletResponse.addCookie(Cookie)
,PortletResponse#addProperty(Cookie)
-
-