Spring Framework

org.springframework.web.portlet.handler
Class ParameterHandlerMapping

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.portlet.handler.AbstractHandlerMapping
          extended by org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping<java.lang.String>
              extended by org.springframework.web.portlet.handler.ParameterHandlerMapping
All Implemented Interfaces:
Aware, ApplicationContextAware, Ordered, HandlerMapping

public class ParameterHandlerMapping
extends AbstractMapBasedHandlerMapping<java.lang.String>

Implementation of the HandlerMapping to map from a request parameter to request handler beans.

The default name of the parameter is "action", but can be changed using setParameterName().

The bean configuration for this mapping will look somthing like this:

 <bean id="parameterHandlerMapping" class="org.springframework.web.portlet.handler.ParameterHandlerMapping">
   <property name="parameterMap">
     <map>
             <entry key="add"><ref bean="addItemHandler"/></entry>
       <entry key="edit"><ref bean="editItemHandler"/></entry>
       <entry key="delete"><ref bean="deleteItemHandler"/></entry>
     </map>
   </property>
 </bean>
Thanks to Rainer Schmitz for suggesting this mapping strategy!

Since:
2.0
Author:
John A. Lewis, Juergen Hoeller
See Also:
ParameterMappingInterceptor

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate
 
Field Summary
static java.lang.String DEFAULT_PARAMETER_NAME
          Default request parameter name to use for mapping to handlers: "action".
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
ParameterHandlerMapping()
           
 
Method Summary
protected  java.lang.String getLookupKey(javax.portlet.PortletRequest request)
          Uses the value of the specified parameter as lookup key.
 void initApplicationContext()
          Calls the registerHandlers method in addition to the superclass's initialization.
 void setParameterMap(java.util.Map<java.lang.String,?> parameterMap)
          Set a Map with parameters as keys and handler beans or bean names as values.
 void setParameterName(java.lang.String parameterName)
          Set the name of the parameter used for mapping to handlers.
 
Methods inherited from class org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
getHandlerInternal, registerHandler, registerHandler, registerHandlers, setLazyInitHandlers
 
Methods inherited from class org.springframework.web.portlet.handler.AbstractHandlerMapping
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initInterceptors, setApplyWebRequestInterceptorsToRenderPhaseOnly, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PARAMETER_NAME

public static final java.lang.String DEFAULT_PARAMETER_NAME
Default request parameter name to use for mapping to handlers: "action".

See Also:
Constant Field Values
Constructor Detail

ParameterHandlerMapping

public ParameterHandlerMapping()
Method Detail

setParameterName

public void setParameterName(java.lang.String parameterName)
Set the name of the parameter used for mapping to handlers.

Default is "action".


setParameterMap

public void setParameterMap(java.util.Map<java.lang.String,?> parameterMap)
Set a Map with parameters as keys and handler beans or bean names as values. Convenient for population with bean references.

Parameters:
parameterMap - map with parameters as keys and beans as values

initApplicationContext

public void initApplicationContext()
                            throws BeansException
Calls the registerHandlers method in addition to the superclass's initialization.

Overrides:
initApplicationContext in class AbstractHandlerMapping
Throws:
ApplicationContextException - in case of initialization errors
BeansException - if thrown by ApplicationContext methods
See Also:
AbstractMapBasedHandlerMapping.registerHandlers(java.util.Map)

getLookupKey

protected java.lang.String getLookupKey(javax.portlet.PortletRequest request)
                                 throws java.lang.Exception
Uses the value of the specified parameter as lookup key.

Specified by:
getLookupKey in class AbstractMapBasedHandlerMapping<java.lang.String>
Parameters:
request - current portlet request
Returns:
the lookup key (never null)
Throws:
java.lang.Exception - if key computation failed
See Also:
setParameterName(java.lang.String)

Spring Framework