org.springframework.web.portlet

## Class GenericPortletBean

- java.lang.Object
- - javax.portlet.GenericPortlet
  - - org.springframework.web.portlet.GenericPortletBean

- All Implemented Interfaces:
    EventPortlet, Portlet, PortletConfig, ResourceServingPortlet, Aware, EnvironmentAware, EnvironmentCapable
  Direct Known Subclasses:
    FrameworkPortlet

      public abstract class GenericPortletBean
      extends GenericPortlet
      implements EnvironmentCapable, EnvironmentAware

  Simple extension of `javax.portlet.GenericPortlet` that treats its config parameters as bean properties.

  A very handy superclass for any type of portlet. Type conversion is automatic. It is also possible for subclasses to specify required properties.

  This portlet leaves request handling to subclasses, inheriting the default behaviour of GenericPortlet (`doDispatch`, `processAction`, etc).

  This portlet superclass has no dependency on a Spring application context, in contrast to the FrameworkPortlet class which loads its own context.

  Since:
    2.0
  Author:
    William G. Thompson, Jr., John A. Lewis, Juergen Hoeller
  See Also:
    `addRequiredProperty(java.lang.String)`, `initPortletBean()`, `GenericPortlet.doDispatch(javax.portlet.RenderRequest, javax.portlet.RenderResponse)`, `GenericPortlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)`, `FrameworkPortlet`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Log` | `logger` Logger available to subclasses

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericPortletBean()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addRequiredProperty(String property)` Subclasses can invoke this method to specify that this property (which must match a JavaBean property they expose) is mandatory, and must be supplied as a config parameter.
    `protected ConfigurableEnvironment` | `createEnvironment()` Create and return a new `StandardPortletEnvironment`.
    `ConfigurableEnvironment` | `getEnvironment()` Return the `Environment` associated with this component.
    `PortletContext` | `getPortletContext()` Overridden method that simply returns `null` when no PortletConfig set yet.
    `String` | `getPortletName()` Overridden method that simply returns `null` when no PortletConfig set yet.
    `void` | `init()` Map config parameters onto bean properties of this portlet, and invoke subclass initialization.
    `protected void` | `initBeanWrapper(BeanWrapper bw)` Initialize the BeanWrapper for this GenericPortletBean, possibly with custom editors.
    `protected void` | `initPortletBean()` Subclasses may override this to perform custom initialization.
    `void` | `setEnvironment(Environment environment)` Set the `Environment` that this object runs in.

    - ### Methods inherited from class javax.portlet.GenericPortlet

      `destroy, doDispatch, doEdit, doHeaders, doHelp, doView, getContainerRuntimeOptions, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, processAction, processEvent, render, serveResource`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected final Log logger

      Logger available to subclasses

  - ### Constructor Detail

    - #### GenericPortletBean

          public GenericPortletBean()

  - ### Method Detail

    - #### addRequiredProperty

          protected final void addRequiredProperty(String property)

      Subclasses can invoke this method to specify that this property (which must match a JavaBean property they expose) is mandatory, and must be supplied as a config parameter. This method would normally be called from a subclass constructor.
      Parameters:
        `property` - name of the required property

    - #### init

          public final void init()
                          throws PortletException

      Map config parameters onto bean properties of this portlet, and invoke subclass initialization.
      Overrides:
        `init` in class `GenericPortlet`
      Throws:
        `PortletException` - if bean properties are invalid (or required properties are missing), or if subclass initialization fails.

    - #### initBeanWrapper

          protected void initBeanWrapper(BeanWrapper bw)
                                  throws BeansException

      Initialize the BeanWrapper for this GenericPortletBean, possibly with custom editors.
      Parameters:
        `bw` - the BeanWrapper to initialize
      Throws:
        `BeansException` - if thrown by BeanWrapper methods
      See Also:
        `PropertyEditorRegistry.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)`

    - #### getPortletName

          public final String getPortletName()

      Overridden method that simply returns `null` when no PortletConfig set yet.
      Specified by:
        `getPortletName` in interface `PortletConfig`
      Overrides:
        `getPortletName` in class `GenericPortlet`
      See Also:
        `GenericPortlet.getPortletConfig()`

    - #### getPortletContext

          public final PortletContext getPortletContext()

      Overridden method that simply returns `null` when no PortletConfig set yet.
      Specified by:
        `getPortletContext` in interface `PortletConfig`
      Overrides:
        `getPortletContext` in class `GenericPortlet`
      See Also:
        `GenericPortlet.getPortletConfig()`

    - #### initPortletBean

          protected void initPortletBean()
                                  throws PortletException

      Subclasses may override this to perform custom initialization. All bean properties of this portlet will have been set before this method is invoked. This default implementation does nothing.
      Throws:
        `PortletException` - if subclass initialization fails

    - #### setEnvironment

          public void setEnvironment(Environment environment)

      Set the `Environment` that this object runs in.
      Specified by:
        `setEnvironment` in interface `EnvironmentAware`
      Throws:
        `IllegalArgumentException` - if environment is not assignable to `ConfigurableEnvironment`.

    - #### getEnvironment

          public ConfigurableEnvironment getEnvironment()

      Return the `Environment` associated with this component.

      If `null`, a new environment will be initialized via `createEnvironment()`.

      Specified by:
        `getEnvironment` in interface `EnvironmentCapable`

    - #### createEnvironment

          protected ConfigurableEnvironment createEnvironment()

      Create and return a new `StandardPortletEnvironment`. Subclasses may override in order to configure the environment or specialize the environment type returned.