org.springframework.web.portlet
Class GenericPortletBean

java.lang.Object
  extended by GenericPortlet
      extended by org.springframework.web.portlet.GenericPortletBean
Direct Known Subclasses:
FrameworkPortlet

public abstract class GenericPortletBean
extends GenericPortlet

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(), #doDispatch, #processAction, FrameworkPortlet

Nested Class Summary
private static class GenericPortletBean.PortletConfigPropertyValues
          PropertyValues implementation created from PortletConfig init parameters.
 
Field Summary
protected  Log logger
          Logger available to subclasses
private  java.util.Set<java.lang.String> requiredProperties
          Set of required properties (Strings) that must be supplied as config parameters to this portlet.
 
Constructor Summary
GenericPortletBean()
           
 
Method Summary
protected  void addRequiredProperty(java.lang.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.
 PortletContext getPortletContext()
          Overridden method that simply returns null when no PortletConfig set yet.
 java.lang.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.
 
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


requiredProperties

private final java.util.Set<java.lang.String> requiredProperties
Set of required properties (Strings) that must be supplied as config parameters to this portlet.

Constructor Detail

GenericPortletBean

public GenericPortletBean()
Method Detail

addRequiredProperty

protected final void addRequiredProperty(java.lang.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.

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 java.lang.String getPortletName()
Overridden method that simply returns null when no PortletConfig set yet.

See Also:
#getPortletConfig()

getPortletContext

public final PortletContext getPortletContext()
Overridden method that simply returns null when no PortletConfig set yet.

See Also:
#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