java.lang.Objectorg.springframework.context.support.ApplicationObjectSupport
org.springframework.web.portlet.handler.AbstractHandlerMapping
org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping
All Implemented Interfaces:
HandlerMapping, Ordered, ApplicationContextAware
This is a combination of the methods used in PortletModeHandlerMapping and ParameterHandlerMapping . Unlike those two classes, this mapping cannot be initialized with properties since it requires a two-level map.
The default name of the parameter is "action", but can be changed using setParameterName() .
By default, the same parameter value may not be used in two different portlet modes. This is so that if the portal itself changes the portlet mode, the request will no longer be valid in the mapping. This behavior can be changed with setAllowDupParameters() .
The bean configuration for this mapping will look somthing like this:
<bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping"> <property name="portletModeParameterMap"> <map> <entry key="view"> <!-- portlet mode: view --> <map> <entry key="add"><ref bean="addItemHandler"/></entry> <entry key="edit"><ref bean="editItemHandler"/></entry> <entry key="delete"><ref bean="deleteItemHandler"/></entry> </map> </entry> <entry key="edit"> <!-- portlet mode: edit --> <map> <entry key="prefs"><ref bean="preferencesHandler"/></entry> <entry key="resetPrefs"><ref bean="resetPreferencesHandler"/></entry> </map> </entry> </map> </property> </bean>
This mapping can be chained ahead of a PortletModeHandlerMapping , which can then provide defaults for each mode and an overall default as well.
Thanks to Rainer Schmitz and Yujin Kim for suggesting this mapping strategy!
John - A. LewisJuergen - Hoeller2.0 - | Field Summary | ||
|---|---|---|
| public static final String | DEFAULT_PARAMETER_NAME | Default request parameter name to use for mapping to handlers: "action". |
| Fields inherited from org.springframework.context.support.ApplicationObjectSupport: |
|---|
| logger |
| Method from org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping Summary: |
|---|
| getLookupKey, initApplicationContext, registerHandler, registerHandler, registerHandlers, setAllowDuplicateParameters, setParameterName, setPortletModeParameterMap |
| Methods from org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping: |
|---|
| getHandlerInternal, getLookupKey, registerHandler, registerHandler, registerHandlers, setLazyInitHandlers |
| Methods from org.springframework.web.portlet.handler.AbstractHandlerMapping: |
|---|
| adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getHandlerInternal, getOrder, initApplicationContext, initInterceptors, setApplyWebRequestInterceptorsToRenderPhaseOnly, setDefaultHandler, setInterceptors, setOrder |
| Methods from org.springframework.context.support.ApplicationObjectSupport: |
|---|
| getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext |
| Methods from java.lang.Object: |
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping Detail: |
|---|
|
registerHandlers method in addition
to the superclass's initialization. |
|
|
|
Doing this is dangerous because the portlet mode can be changed by the portal itself and the only way to see that is a rerender of the portlet. If the same parameter value is legal in multiple modes, then a change in mode could result in a matched mapping that is not intended and the user could end up in a strange place in the application. |
Default is "action". |
Convenient for population with bean references. |