Portlet API (V0.7.1) : Interface RenderResponse

Package | Class | Tree | Deprecated | Index | Help
| Portlet API (V0.7.1)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.portlet
Interface RenderResponse

All Superinterfaces:
  PortletResponse

public interface RenderResponse
extends PortletResponse

The `RenderResponse` defines an object to assist a portlet in sending a response to the portal. The portlet container creates a RenderResponse object and passes it as an argument to the render method of the portlet.

See the Internet RFCs such as RFC 2045 for more information on MIME.

See Also:
  `RenderRequest`, `PortletResponse`

Field Summary
`static java.lang.String` | `EXPIRATION_CACHE` Property to set the expiration time in seconds for this response using the `setProperty` method.

Method Summary
`PortletURL` | `createActionURL()` Creates a portlet URL pointing to the current portlet mode and current window state, triggering an action request and a render request.
`PortletURL` | `createRenderURL()` Creates a portlet URL pointing to the current portlet mode and current window state, triggering a render call.
`java.lang.String` | `encodeNamespace(java.lang.String aValue)` Maps the given string value into this portlet namespace and therefore ensures the uniqueness of the string value in the whole portal page.
`void` | `flushBuffer()` Forces any content in the buffer to be written to the client.
`int` | `getBufferSize()` Returns the actual buffer size used for the response.
`java.lang.String` | `getCharacterEncoding()` Returns the name of the charset used for the MIME body sent in this response.
`java.lang.String` | `getContentType()` Returns the MIME type that can be used to contribute markup to the render response.
`java.util.Locale` | `getLocale()` Returns the locale assigned to the response.
`java.io.OutputStream` | `getPortletOutputStream()` Returns a `OutputStream` suitable for writing binary data in the response.
`java.io.PrintWriter` | `getWriter()` Returns a PrintWriter object that can send character text to the portal.
`boolean` | `isCommitted()` Returns a boolean indicating if the response has been committed.
`void` | `reset()` Clears any data that exists in the buffer as well as the properties set.
`void` | `resetBuffer()` Clears the content of the underlying buffer in the response without clearing properties set.
`void` | `setBufferSize(int size)` Sets the preferred buffer size for the body of the response.
`void` | `setContentType(java.lang.String type)` Sets the MIME type for the render response.
`void` | `setTitle(java.lang.String title)` This method can be called to set the title of a portlet.

Methods inherited from interface javax.portlet.PortletResponse
`addProperty, encodeURL, setProperty`

Field Detail

### EXPIRATION_CACHE

    public static final java.lang.String EXPIRATION_CACHE

  Property to set the expiration time in seconds for this response using the `setProperty` method.

  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"`.

Method Detail

### getContentType

    public 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 retuns `null`.

  Returns:
    the MIME type of the response, or `null` if no content type is set
  See Also:
    `setContentType(java.lang.String)`

### createRenderURL

    public PortletURL createRenderURL()

  Creates a portlet URL pointing to the current portlet mode and current window state, triggering a render call. 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

    public PortletURL createActionURL()

  Creates a portlet URL pointing to the current portlet mode and current window state, triggering an action request and 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 action URL

### encodeNamespace

    public java.lang.String encodeNamespace(java.lang.String aValue)

  Maps the given string value into this portlet namespace and therefore ensures the uniqueness of the string value in the whole portal page. This method should be applied to every variable or name used in the output stream. For example a function name in javascript.

  If the string passed to the `encodeNamespace` method must be a valid identifier as defined in the 3.8 Identifier Section of the Java Language Specification Second Edition, the returned string is also a valid identifier.

  If `null` is passed as value this method returns the portlet namespace.

  Parameters:
    `aValue` - the name to be mapped
  Returns:
    the mapped name

### setTitle

    public void setTitle(java.lang.String title)

  This method can be called to set the title of a portlet.

  The value can be either a text String or a resource URI.

  Parameters:
    `title` - portlet title as text String or resource URI

### setContentType

    public void setContentType(java.lang.String type)

  Sets the MIME type for the render response. The portlet must set the content type before calling `getWriter()` or `getPortletOutputStream()`.

  Calling `setContentType` after `getWriter` or `getOutputStream` does 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 by `PortletRequest.getResponseContentTypes`
  See Also:
    `PortletRequest.getResponseContentTypes()`, `getContentType()`

### getCharacterEncoding

    public java.lang.String getCharacterEncoding()

  Returns the name of the charset used for the MIME body sent in this response.

  See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt) for more information about character encoding and MIME.

  Returns:
    a `String` specifying the name of the charset, for example, `ISO-8859-1`

### getWriter

    public java.io.PrintWriter getWriter()
                                  throws java.io.IOException

  Returns 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 `PrintWriter` object that can return character data to the portal
  Throws:
    `java.io.IOException` - if an input or output exception occurred
    `java.lang.IllegalStateException` - if the `getPortletOutputStream` method has been called on this response, or if no content type was set using the `setContentType` method.
  See Also:
    `setContentType(java.lang.String)`, `getPortletOutputStream()`

### getLocale

    public java.util.Locale getLocale()

  Returns the locale assigned to the response.
  Returns:
    Locale of this response

### setBufferSize

    public 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 throws 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

    public int getBufferSize()

  Returns the actual buffer size used for the response. If no buffering is used, this method returns 0.

  Depending on the portlet container implementation the buffer may be shared by serveral portlets.

  Returns:
    the actual buffer size used
  See Also:
    `setBufferSize(int)`, `flushBuffer()`, `isCommitted()`, `reset()`

### flushBuffer

    public void flushBuffer()
                     throws java.io.IOException

  Forces 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

    public 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 an `IllegalStateException`.
  Throws:
    `IllegalStateException` - if this method is called after response is comitted
  See Also:
    `setBufferSize(int)`, `getBufferSize()`, `isCommitted()`, `reset()`

### isCommitted

    public 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

    public 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 an `IllegalStateException`.
  Throws:
    `java.lang.IllegalStateException` - if the response has already been committed
  See Also:
    `setBufferSize(int)`, `getBufferSize()`, `flushBuffer()`, `isCommitted()`

### getPortletOutputStream

    public java.io.OutputStream getPortletOutputStream()
                                                throws java.io.IOException

  Returns a `OutputStream` suitable 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 `OutputStream` for writing binary data
  Throws:
    `java.lang.IllegalStateException` - if the `getWriter` method has been called on this response, or if no content type was set using the `setContentType` method.
    `java.io.IOException` - if an input or output exception occurred
  See Also:
    `setContentType(java.lang.String)`, `getWriter()`

Package | Class | Tree | Deprecated | Index | Help
| Portlet API (V0.7.1)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD