org.springframework.web.portlet.mvc
Interface Controller

All Known Implementing Classes:
AbstractCommandController, AbstractController, AbstractFormController, AbstractWizardFormController, BaseCommandController, ParameterizableViewController, PortletModeNameViewController, PortletWrappingController, SimpleFormController

public interface Controller

Base portlet Controller interface, representing a component that receives RenderRequest/RenderResponse and ActionRequest/ActionResponse like a Portlet but is able to participate in an MVC workflow.

Any implementation of the portlet Controller interface should be a reusable, threadsafe class, capable of handling multiple portlet requests throughout the lifecycle of an application. To be able to configure Controller(s) in an easy way, Controllers are usually JavaBeans.

Workflow:

After the DispatcherPortlet has received a request and has done its work to resolve locales, themes and suchlike, it tries to resolve a Controller to handle that request, using a HandlerMapping. When a Controller has been found, the handleRenderRequest or handleActionRequest method will be invoked, which is responsible for handling the actual request and - if applicable - returning an appropriate ModelAndView. So actually, these method are the main entrypoint for the DispatcherPortlet which delegates requests to controllers. These method - and also this interface - should preferrably not be implemented by custom controllers directly, since abstract controllers also provided by this package already provide a lot of functionality for typical use cases in portlet applications. A few examples of those controllers: AbstractController, AbstractCommandController, AbstractFormController, SimpleFormController.

So basically any direct implementation of the Controller interface just handles RenderRequests/ActionRequests and should return a ModelAndView, to be further used by the DispatcherPortlet. Any additional functionality such as optional validation, form handling, etc should be obtained through extending one of the abstract controller classes mentioned above.

Since:
2.0
Author:
William G. Thompson, Jr., John A. Lewis
See Also:
SimpleControllerHandlerAdapter, AbstractController, AbstractCommandController, AbstractFormController, SimpleFormController, ApplicationContextAware, ResourceLoaderAware, PortletContextAware

Method Summary
 void handleActionRequest(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          Process the action request.
 ModelAndView handleRenderRequest(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
          Process the render request and return a ModelAndView object which the DispatcherPortlet will render.
 

Method Detail

handleActionRequest

void handleActionRequest(javax.portlet.ActionRequest request,
                         javax.portlet.ActionResponse response)
                         throws Exception
Process the action request. There is nothing to return.

Parameters:
request - current portlet action request
response - current portlet action response
Throws:
Exception - in case of errors

handleRenderRequest

ModelAndView handleRenderRequest(javax.portlet.RenderRequest request,
                                 javax.portlet.RenderResponse response)
                                 throws Exception
Process the render request and return a ModelAndView object which the DispatcherPortlet will render. A null return value is not an error: It indicates that this object completed request processing itself, thus there is no ModelAndView to render.

Parameters:
request - current portlet render request
response - current portlet render response
Returns:
a ModelAndView to render, or null if handled directly
Throws:
Exception - in case of errors


Copyright © 2002-2008 The Spring Framework.