Package 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 ofjavax.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
Constructor Summary
Constructors Constructor Description GenericPortletBean()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 newStandardPortletEnvironment
.ConfigurableEnvironment
getEnvironment()
Return theEnvironment
associated with this component (may benull
or a default environment).PortletContext
getPortletContext()
Overridden method that simply returnsnull
when no PortletConfig set yet.String
getPortletName()
Overridden method that simply returnsnull
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 theEnvironment
that this component 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
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 classGenericPortlet
- 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 returnsnull
when no PortletConfig set yet.- Specified by:
getPortletName
in interfacePortletConfig
- Overrides:
getPortletName
in classGenericPortlet
- See Also:
GenericPortlet.getPortletConfig()
getPortletContext
public final PortletContext getPortletContext()
Overridden method that simply returnsnull
when no PortletConfig set yet.- Specified by:
getPortletContext
in interfacePortletConfig
- Overrides:
getPortletContext
in classGenericPortlet
- 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 theEnvironment
that this component runs in.- Specified by:
setEnvironment
in interfaceEnvironmentAware
- Throws:
IllegalArgumentException
- if environment is not assignable toConfigurableEnvironment
.
getEnvironment
public ConfigurableEnvironment getEnvironment()
Return theEnvironment
associated with this component (may benull
or a default environment).If
null
, a new environment will be initialized viacreateEnvironment()
.- Specified by:
getEnvironment
in interfaceEnvironmentCapable
createEnvironment
protected ConfigurableEnvironment createEnvironment()
Create and return a newStandardPortletEnvironment
. Subclasses may override in order to configure the environment or specialize the environment type returned.