Class SimplePortletHandlerAdapter
- java.lang.Object
- org.springframework.web.portlet.handler.SimplePortletHandlerAdapter
- All Implemented Interfaces:
Aware,PortletContextAware,HandlerAdapter
public class SimplePortletHandlerAdapter extends Object implements HandlerAdapter, PortletContextAware
Adapter to use the Portlet interface with the generic DispatcherPortlet. Calls the Portlet'srenderandprocessActionmethods to handle a request.This adapter is not activated by default; it needs to be defined as a bean in the DispatcherPortlet context. It will automatically apply to mapped handler beans that implement the Portlet interface then.
Note that Portlet instances defined as bean will not receive initialization and destruction callbacks, unless a special post-processor such as SimplePortletPostProcessor is defined in the DispatcherPortlet context.
Alternatively, consider wrapping a Portlet with Spring's PortletWrappingController. This is particularly appropriate for existing Portlet classes, allowing to specify Portlet initialization parameters, etc.
- Since:
- 2.0
- Author:
- John A. Lewis
- See Also:
Portlet,SimplePortletPostProcessor,PortletWrappingController
Constructor Summary
Constructors Constructor Description SimplePortletHandlerAdapter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandleAction(ActionRequest request, ActionResponse response, Object handler)Use the given handler to handle this action request.voidhandleEvent(EventRequest request, EventResponse response, Object handler)Use the given handler to handle this event request.ModelAndViewhandleRender(RenderRequest request, RenderResponse response, Object handler)Use the given handler to handle this render request.ModelAndViewhandleResource(ResourceRequest request, ResourceResponse response, Object handler)Use the given handler to handle this resource request.voidsetPortletContext(PortletContext portletContext)Set the PortletContext that this object runs in.booleansupports(Object handler)Given a handler instance, return whether or not this HandlerAdapter can support it.
Constructor Detail
SimplePortletHandlerAdapter
public SimplePortletHandlerAdapter()
Method Detail
setPortletContext
public void setPortletContext(PortletContext portletContext)
Description copied from interface:PortletContextAwareSet the PortletContext that this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext.
- Specified by:
setPortletContextin interfacePortletContextAware- Parameters:
portletContext- PortletContext object to be used by this object
supports
public boolean supports(Object handler)
Description copied from interface:HandlerAdapterGiven a handler instance, return whether or not this HandlerAdapter can support it. Typical HandlerAdapters will base the decision on the handler type. HandlerAdapters will usually only support one handler type each.A typical implementation:
return (handler instanceof MyHandler);- Specified by:
supportsin interfaceHandlerAdapter- Parameters:
handler- handler object to check- Returns:
- whether or not this object can use the given handler
handleAction
public void handleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception
Description copied from interface:HandlerAdapterUse the given handler to handle this action request. The workflow that is required may vary widely.- Specified by:
handleActionin interfaceHandlerAdapter- Parameters:
request- current action requestresponse- current action responsehandler- handler to use. This object must have previously been passed to thesupportsmethod of this interface, which must have returned true.- Throws:
Exception- in case of errors- See Also:
Portlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
handleRender
public ModelAndView handleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception
Description copied from interface:HandlerAdapterUse the given handler to handle this render request. The workflow that is required may vary widely.- Specified by:
handleRenderin interfaceHandlerAdapter- Parameters:
request- current render requestresponse- current render responsehandler- handler to use. This object must have previously been passed to thesupportsmethod of this interface, which must have returnedtrue.- Returns:
- ModelAndView object with the name of the view and the required model data, or
nullif the request has been handled directly - Throws:
Exception- in case of errors- See Also:
Portlet.render(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
handleResource
public ModelAndView handleResource(ResourceRequest request, ResourceResponse response, Object handler) throws Exception
Description copied from interface:HandlerAdapterUse the given handler to handle this resource request. The workflow that is required may vary widely.- Specified by:
handleResourcein interfaceHandlerAdapter- Parameters:
request- current render requestresponse- current render responsehandler- handler to use. This object must have previously been passed to thesupportsmethod of this interface, which must have returnedtrue.- Returns:
- ModelAndView object with the name of the view and the required model data, or
nullif the request has been handled directly - Throws:
Exception- in case of errors- See Also:
ResourceServingPortlet.serveResource(javax.portlet.ResourceRequest, javax.portlet.ResourceResponse)
handleEvent
public void handleEvent(EventRequest request, EventResponse response, Object handler) throws Exception
Description copied from interface:HandlerAdapterUse the given handler to handle this event request. The workflow that is required may vary widely.- Specified by:
handleEventin interfaceHandlerAdapter- Parameters:
request- current action requestresponse- current action responsehandler- handler to use. This object must have previously been passed to thesupportsmethod of this interface, which must have returned true.- Throws:
Exception- in case of errors- See Also:
EventPortlet.processEvent(javax.portlet.EventRequest, javax.portlet.EventResponse)