The Spring Framework

## org.springframework.web.portlet.handler
Class PortletContentGenerator

    java.lang.Object
      org.springframework.context.support.ApplicationObjectSupport
          org.springframework.web.portlet.context.PortletApplicationObjectSupport
              org.springframework.web.portlet.handler.PortletContentGenerator

All Implemented Interfaces:
  ApplicationContextAware, PortletContextAware

Direct Known Subclasses:
  AbstractController, AnnotationMethodHandlerAdapter

    public abstract class PortletContentGenerator

extends PortletApplicationObjectSupport

Convenient superclass for any kind of web content generator, like `AbstractController`. Can also be used for custom handlers that have their own `HandlerAdapter`.

Supports portlet cache control options.

Since:
  2.0
Author:
  Juergen Hoeller, John A. Lewis
See Also:
  `setCacheSeconds(int)`, `setRequireSession(boolean)`

Field Summary

Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
`logger`

Constructor Summary
`PortletContentGenerator()`

Method Summary
`protected void` `applyCacheSeconds(javax.portlet.RenderResponse response, int seconds)` Apply the given cache seconds to the render response
`protected void` `cacheForSeconds(javax.portlet.RenderResponse response, int seconds)` Set portlet response to allow caching for the given number of seconds.
`protected void` `check(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response)` Check and prepare the given request and response according to the settings of this generator.
`protected void` `checkAndPrepare(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)` Check and prepare the given request and response according to the settings of this generator.
`protected void` `checkAndPrepare(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, int cacheSeconds)` Check and prepare the given request and response according to the settings of this generator.
`int` `getCacheSeconds()` Return the number of seconds that content is cached.
`boolean` `isRequireSession()` Return whether a session is required to handle requests.
`protected void` `preventCaching(javax.portlet.RenderResponse response)` Prevent the render response from being cached.
`void` `setCacheSeconds(int seconds)` Cache content for the given number of seconds.
`void` `setRequireSession(boolean requireSession)` Set whether a session should be required to handle requests.

Methods inherited from class org.springframework.web.portlet.context.PortletApplicationObjectSupport
`getPortletContext, getTempDir, isContextRequired, setPortletContext`

Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
`getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, requiredContextClass, setApplicationContext`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PortletContentGenerator

    public PortletContentGenerator()

Method Detail

### setRequireSession

    public final void setRequireSession(boolean requireSession)

  Set whether a session should be required to handle requests.

### isRequireSession

    public final boolean isRequireSession()

  Return whether a session is required to handle requests.

### setCacheSeconds

    public final void setCacheSeconds(int seconds)

  Cache content for the given number of seconds. Default is -1, indicating no override of portlet content caching.

  Only if this is set to 0 (no cache) or a positive value (cache for this many seconds) will this class override the portlet settings.

  The cache setting can be overwritten by subclasses, before content is generated.

### getCacheSeconds

    public final int getCacheSeconds()

  Return the number of seconds that content is cached.

### check

    protected final void check(javax.portlet.PortletRequest request,
                               javax.portlet.PortletResponse response)
                        throws javax.portlet.PortletException

  Check and prepare the given request and response according to the settings of this generator. Checks for a required session, and applies the number of cache seconds configured for this generator (if it is a render request/response).

  Parameters:
    `request` - current portlet request
    `response` - current portlet response
  Throws:
    `javax.portlet.PortletException` - if the request cannot be handled because a check failed

### checkAndPrepare

    protected final void checkAndPrepare(javax.portlet.RenderRequest request,
                                         javax.portlet.RenderResponse response)
                                  throws javax.portlet.PortletException

  Check and prepare the given request and response according to the settings of this generator. Checks for a required session, and applies the number of cache seconds configured for this generator (if it is a render request/response).

  Parameters:
    `request` - current portlet request
    `response` - current portlet response
  Throws:
    `javax.portlet.PortletException` - if the request cannot be handled because a check failed

### checkAndPrepare

    protected final void checkAndPrepare(javax.portlet.RenderRequest request,
                                         javax.portlet.RenderResponse response,
                                         int cacheSeconds)
                                  throws javax.portlet.PortletException

  Check and prepare the given request and response according to the settings of this generator. Checks for a required session, and applies the given number of cache seconds (if it is a render request/response).

  Parameters:
    `request` - current portlet request
    `response` - current portlet response
    `cacheSeconds` - positive number of seconds into the future that the response should be cacheable for, 0 to prevent caching
  Throws:
    `javax.portlet.PortletException` - if the request cannot be handled because a check failed

### preventCaching

    protected final void preventCaching(javax.portlet.RenderResponse response)

  Prevent the render response from being cached.

### cacheForSeconds

    protected final void cacheForSeconds(javax.portlet.RenderResponse response,
                                         int seconds)

  Set portlet response to allow caching for the given number of seconds.

  Parameters:
    `response` - current portlet render response
    `seconds` - number of seconds into the future that the response should be cacheable for

### applyCacheSeconds

    protected final void applyCacheSeconds(javax.portlet.RenderResponse response,
                                           int seconds)

  Apply the given cache seconds to the render response

  Parameters:
    `response` - current portlet render response
    `seconds` - positive number of seconds into the future that the response should be cacheable for, 0 to prevent caching

The Spring Framework

Copyright © 2002-2008 The Spring Framework.