The Spring Framework

org.springframework.web.portlet
Class GenericPortletBean

java.lang.Object
  extended by javax.portlet.GenericPortlet
      extended by org.springframework.web.portlet.GenericPortletBean
All Implemented Interfaces:
Portlet, PortletConfig
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(), GenericPortlet.doDispatch(javax.portlet.RenderRequest, javax.portlet.RenderResponse), GenericPortlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse), FrameworkPortlet

Field Summary
protected  Log logger
          Logger available to subclasses
 
Constructor Summary
GenericPortletBean()
           
 
Method Summary
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.
 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.
 
Methods inherited from class javax.portlet.GenericPortlet
destroy, doDispatch, doEdit, doHelp, doView, getInitParameter, getInitParameterNames, getPortletConfig, getResourceBundle, getTitle, init, processAction, render
 
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

The Spring Framework

Copyright © 2002-2007 The Spring Framework.