Interface RenderResponse
-
- All Superinterfaces:
PortletResponse
public interface RenderResponse extends PortletResponse
TheRenderResponsedefines an object to assist a portlet in sending a response to the portal. It extends thePortletResponseinterface to provide specific render response functionality to portlets.
The portlet container creates aRenderResponseobject and passes it as argument to the portlet'srendermethod.- See Also:
RenderRequest,PortletResponse
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEXPIRATION_CACHEProperty to set the expiration time in seconds for this response using thesetPropertymethod.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PortletURLcreateActionURL()Creates a portlet URL targeting the portlet.PortletURLcreateRenderURL()Creates a portlet URL targeting the portlet.voidflushBuffer()Forces any content in the buffer to be written to the client.intgetBufferSize()Returns the actual buffer size used for the response.java.lang.StringgetCharacterEncoding()Returns the name of the charset used for the MIME body sent in this response.java.lang.StringgetContentType()Returns the MIME type that can be used to contribute markup to the render response.java.util.LocalegetLocale()Returns the locale assigned to the response.java.lang.StringgetNamespace()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.OutputStreamgetPortletOutputStream()Returns aOutputStreamsuitable for writing binary data in the response.java.io.PrintWritergetWriter()Returns a PrintWriter object that can send character text to the portal.booleanisCommitted()Returns a boolean indicating if the response has been committed.voidreset()Clears any data that exists in the buffer as well as the properties set.voidresetBuffer()Clears the content of the underlying buffer in the response without clearing properties set.voidsetBufferSize(int size)Sets the preferred buffer size for the body of the response.voidsetContentType(java.lang.String type)Sets the MIME type for the render response.voidsetTitle(java.lang.String title)This method sets the title of the portlet.-
Methods inherited from interface javax.portlet.PortletResponse
addProperty, encodeURL, setProperty
-
-
-
-
Field Detail
-
EXPIRATION_CACHE
static final java.lang.String EXPIRATION_CACHE
Property to set the expiration time in seconds for this response using thesetPropertymethod.If the expiration value is set to 0, caching is disabled for this portlet; if the value is set to -1, the cache does not expire.
The value is
"portlet.expiration-cache".- See Also:
- Constant Field Values
-
-
Method Detail
-
getContentType
java.lang.String getContentType()
Returns the MIME type that can be used to contribute markup to the render response.If no content type was set previously using the
setContentType(java.lang.String)method this method retunsnull.- Returns:
- the MIME type of the response, or
nullif no content type is set - See Also:
setContentType(java.lang.String)
-
createRenderURL
PortletURL createRenderURL()
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.
- Returns:
- a portlet render URL
-
createActionURL
PortletURL createActionURL()
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.
- Returns:
- a portlet action URL
-
getNamespace
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.- Returns:
- the namespace
-
setTitle
void setTitle(java.lang.String title)
This method sets the title of the portlet.The value can be a text String
- Parameters:
title- portlet title as text String or resource URI
-
setContentType
void setContentType(java.lang.String type)
Sets the MIME type for the render response. The portlet must set the content type before callinggetWriter()orgetPortletOutputStream().Calling
setContentTypeaftergetWriterorgetOutputStreamdoes not change the content type.- Parameters:
type- the content MIME type- Throws:
java.lang.IllegalArgumentException- if the given type is not in the list returned byPortletRequest.getResponseContentTypes- See Also:
PortletRequest.getResponseContentTypes(),getContentType()
-
getCharacterEncoding
java.lang.String getCharacterEncoding()
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.
- Returns:
- a
Stringspecifying the name of the charset, for example,ISO-8859-1
-
getWriter
java.io.PrintWriter getWriter() throws java.io.IOExceptionReturns 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
setContentType(java.lang.String)method.Either this method or
getPortletOutputStream()may be called to write the body, not both.- Returns:
- a
PrintWriterobject that can return character data to the portal - Throws:
java.io.IOException- if an input or output exception occurredjava.lang.IllegalStateException- if thegetPortletOutputStreammethod has been called on this response, or if no content type was set using thesetContentTypemethod.- See Also:
setContentType(java.lang.String),getPortletOutputStream()
-
getLocale
java.util.Locale getLocale()
Returns the locale assigned to the response.- Returns:
- Locale of this response
-
setBufferSize
void setBufferSize(int size)
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.- Parameters:
size- the preferred buffer size- Throws:
java.lang.IllegalStateException- if this method is called after content has been written, or the portlet container does not support buffering- See Also:
getBufferSize(),flushBuffer(),isCommitted(),reset()
-
getBufferSize
int getBufferSize()
Returns the actual buffer size used for the response. If no buffering is used, this method returns 0.- Returns:
- the actual buffer size used
- See Also:
setBufferSize(int),flushBuffer(),isCommitted(),reset()
-
flushBuffer
void flushBuffer() throws java.io.IOExceptionForces any content in the buffer to be written to the client. A call to this method automatically commits the response.- Throws:
java.io.IOException- if an error occured when writing the output- See Also:
setBufferSize(int),getBufferSize(),isCommitted(),reset()
-
resetBuffer
void resetBuffer()
Clears the content of the underlying buffer in the response without clearing properties set. If the response has been committed, this method throws anIllegalStateException.- Throws:
java.lang.IllegalStateException- if this method is called after response is comitted- See Also:
setBufferSize(int),getBufferSize(),isCommitted(),reset()
-
isCommitted
boolean isCommitted()
Returns a boolean indicating if the response has been committed.- Returns:
- a boolean indicating if the response has been committed
- See Also:
setBufferSize(int),getBufferSize(),flushBuffer(),reset()
-
reset
void reset()
Clears any data that exists in the buffer as well as the properties set. If the response has been committed, this method throws anIllegalStateException.- Throws:
java.lang.IllegalStateException- if the response has already been committed- See Also:
setBufferSize(int),getBufferSize(),flushBuffer(),isCommitted()
-
getPortletOutputStream
java.io.OutputStream getPortletOutputStream() throws java.io.IOExceptionReturns aOutputStreamsuitable 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
setContentType(java.lang.String)method.Calling
flush()on the OutputStream commits the response.Either this method or
getWriter()may be called to write the body, not both.- Returns:
- a
OutputStreamfor writing binary data - Throws:
java.lang.IllegalStateException- if thegetWritermethod has been called on this response, or if no content type was set using thesetContentTypemethod.java.io.IOException- if an input or output exception occurred- See Also:
setContentType(java.lang.String),getWriter()
-
-