The Spring Framework

## org.springframework.web.portlet.handler
Class PortletModeHandlerMapping

    java.lang.Object
      org.springframework.context.support.ApplicationObjectSupport
          org.springframework.web.portlet.handler.AbstractHandlerMapping
              org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
                  org.springframework.web.portlet.handler.PortletModeHandlerMapping

All Implemented Interfaces:
  ApplicationContextAware, Ordered, HandlerMapping

    public class PortletModeHandlerMapping

extends AbstractMapBasedHandlerMapping

Implementation of the `HandlerMapping` interface to map from the current PortletMode to request handler beans.

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

            <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
                    <property name="portletModeMap">
                            <map>
                                    <entry key="view"><ref bean="viewHandler"/></entry>
                                    <entry key="edit"><ref bean="editHandler"/></entry>
                                    <entry key="help"><ref bean="helpHandler"/></entry>
                            </map>
                    </property>
            </bean>

Since:
  2.0
Author:
  William G. Thompson, Jr., John A. Lewis

Nested Class Summary

Nested classes/interfaces inherited from class org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
`AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate`

Field Summary

Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
`logger`

Fields inherited from interface org.springframework.core.Ordered
`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

Constructor Summary
`PortletModeHandlerMapping()`

Method Summary
`protected Object` `getLookupKey(javax.portlet.PortletRequest request)` Uses the current PortletMode as lookup key.
`void` `initApplicationContext()` Calls the `registerHandlers` method in addition to the superclass's initialization.
`protected void` `registerHandlers(Map portletModeMap)` Register all handlers specified in the Portlet mode map for the corresponding modes.
`void` `setMappings(Properties mappings)` Set PortletMode to handler bean name mappings from a Properties object.
`void` `setPortletModeMap(Map portletModeMap)` Set a Map with PortletModes as keys and handler beans as values.

Methods inherited from class org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
`getHandlerInternal, registerHandler, registerHandler, 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`

Constructor Detail

### PortletModeHandlerMapping

    public PortletModeHandlerMapping()

Method Detail

### setMappings

    public void setMappings(Properties mappings)

  Set PortletMode to handler bean name mappings from a Properties object.

  Parameters:
    `mappings` - properties with PortletMode names as keys and bean names as values

### setPortletModeMap

    public void setPortletModeMap(Map portletModeMap)

  Set a Map with PortletModes as keys and handler beans as values. Convenient for population with bean references.

  Parameters:
    `portletModeMap` - map with PortletMode names as keys and beans or bean names 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:
    `registerHandlers(java.util.Map)`

### registerHandlers

    protected void registerHandlers(Map portletModeMap)
                             throws BeansException

  Register all handlers specified in the Portlet mode map for the corresponding modes.

  Overrides:
    `registerHandlers` in class `AbstractMapBasedHandlerMapping`
  Parameters:
    `portletModeMap` - Map with mode names as keys and handler beans or bean names as values
  Throws:
    `BeansException` - if the handler couldn't be registered

### getLookupKey

    protected Object getLookupKey(javax.portlet.PortletRequest request)
                           throws Exception

  Uses the current PortletMode as lookup key.

  Specified by:
    `getLookupKey` in class `AbstractMapBasedHandlerMapping`
  Parameters:
    `request` - current portlet request
  Returns:
    the lookup key (never `null`)
  Throws:
    `Exception` - if key computation failed

The Spring Framework

Copyright © 2002-2008 The Spring Framework.