public class VaadinPortletResponse extends Object implements VaadinResponse
PortletResponse
and its subclasses.VaadinResponse
,
VaadinPortletRequest
,
Serialized FormConstructor and Description |
---|
VaadinPortletResponse(javax.portlet.PortletResponse response,
VaadinPortletService vaadinService)
Wraps a portlet response and an associated vaadin service.
|
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. |
javax.portlet.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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCurrent, setNoCacheHeaders
public VaadinPortletResponse(javax.portlet.PortletResponse response, VaadinPortletService vaadinService)
response
- the portlet response to wrapvaadinService
- the associated vaadin servicepublic OutputStream getOutputStream() throws IOException
VaadinResponse
OutputStream
for writing binary data in the
response.
Either this method or getWriter() may be called to write the response, not both.
getOutputStream
in interface VaadinResponse
OutputStream
for writing binary dataIOException
- if an input or output exception occurredVaadinResponse.getWriter()
,
ServletResponse.getOutputStream()
,
MimeResponse.getPortletOutputStream()
public javax.portlet.PortletResponse getPortletResponse()
public void setContentType(String type)
VaadinResponse
VaadinResponse.getWriter()
is invoked, the returned
PrintWriter will automatically use the defined charset.setContentType
in interface VaadinResponse
type
- a string specifying the MIME type of the contentServletResponse.setContentType(String)
,
MimeResponse.setContentType(String)
public void setContentLength(int len)
VaadinResponse
setContentLength
in interface VaadinResponse
len
- an integer specifying the length of the content being returned
to the clientpublic PrintWriter getWriter() throws IOException
VaadinResponse
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.
getWriter
in interface VaadinResponse
PrintWriter
for writing character textIOException
- if an input or output exception occurredVaadinResponse.getOutputStream()
,
ServletResponse.getWriter()
,
MimeResponse.getWriter()
public void setStatus(int responseStatus)
VaadinResponse
VaadinResponse.sendError(int, String)
instead.setStatus
in interface VaadinResponse
responseStatus
- the status code to setHttpServletResponse.setStatus(int)
,
ResourceResponse.HTTP_STATUS_CODE
public void setHeader(String name, String value)
VaadinResponse
setHeader
in interface VaadinResponse
name
- the name of the headervalue
- the header value.HttpServletResponse.setHeader(String, String)
,
PortletResponse.setProperty(String, String)
public void setDateHeader(String name, long timestamp)
VaadinResponse
setDateHeader
in interface VaadinResponse
name
- the name of the headertimestamp
- the number of milliseconds since epochHttpServletResponse.setDateHeader(String, long)
public void setCacheTime(long milliseconds)
VaadinResponse
setCacheTime
in interface VaadinResponse
milliseconds
- Cache time in millisecondspublic void sendError(int errorCode, String message) throws IOException
VaadinResponse
sendError
in interface VaadinResponse
errorCode
- the HTTP status codemessage
- a message to accompany the errorIOException
- if an input or output exception occursHttpServletResponse.sendError(int, String)
public VaadinPortletService getService()
VaadinResponse
getService
in interface VaadinResponse
VaadinService
public void addCookie(javax.servlet.http.Cookie cookie)
VaadinResponse
addCookie
in interface VaadinResponse
cookie
- the Cookie to return to the clientHttpServletResponse.addCookie(Cookie)
,
PortletResponse.addProperty(Cookie)
Copyright © 2018 Vaadin Ltd. All rights reserved.