org.springframework.web.servlet.mvc.throwaway
Class ThrowawayControllerHandlerAdapter

java.lang.Object
  extended by org.springframework.web.servlet.mvc.throwaway.ThrowawayControllerHandlerAdapter
All Implemented Interfaces:
HandlerAdapter

public class ThrowawayControllerHandlerAdapter
extends Object
implements HandlerAdapter

Adapter to use the ThrowawayController workflow interface with the generic DispatcherServlet. Does not support last-modified checks.

This is an SPI class, not used directly by application code. It can be explicitly configured in a DispatcherServlet context, to use a customized version instead of the default ThrowawayControllerHandlerAdapter.

Since:
08.12.2003
Author:
Juergen Hoeller

Field Summary
static String DEFAULT_COMMAND_NAME
           
 
Constructor Summary
ThrowawayControllerHandlerAdapter()
           
 
Method Summary
protected  ServletRequestDataBinder createBinder(HttpServletRequest request, ThrowawayController command)
          Create a new binder instance for the given command and request.
 String getCommandName()
          Return the name of the command in the model.
 long getLastModified(HttpServletRequest request, Object handler)
          This implementation always returns -1, as last-modified checks are not supported.
 ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
          This implementation binds request parameters to the ThrowawayController instance and then calls execute on it.
protected  void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
          Initialize the given binder instance, for example with custom editors.
 void setCommandName(String commandName)
          Set the name of the command in the model.
 boolean supports(Object handler)
          Given a handler instance, return whether or not this HandlerAdapter can support it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COMMAND_NAME

public static final String DEFAULT_COMMAND_NAME
See Also:
Constant Field Values
Constructor Detail

ThrowawayControllerHandlerAdapter

public ThrowawayControllerHandlerAdapter()
Method Detail

setCommandName

public final void setCommandName(String commandName)
Set the name of the command in the model. The command object will be included in the model under this name.


getCommandName

public final String getCommandName()
Return the name of the command in the model.


supports

public boolean supports(Object handler)
Description copied from interface: HandlerAdapter
Given 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:
supports in interface HandlerAdapter
Parameters:
handler - handler object to check
Returns:
whether or not this object can use the given handler

handle

public ModelAndView handle(HttpServletRequest request,
                           HttpServletResponse response,
                           Object handler)
                    throws Exception
This implementation binds request parameters to the ThrowawayController instance and then calls execute on it.

Specified by:
handle in interface HandlerAdapter
Parameters:
request - current HTTP request
response - current HTTP response
handler - handler to use. This object must have previously been passed to the supports method of this interface, which must have returned true.
Returns:
ModelAndView object with the name of the view and the required model data, or null if the request has been handled directly
Throws:
Exception - in case of errors
See Also:
createBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.servlet.mvc.throwaway.ThrowawayController), ThrowawayController.execute()

createBinder

protected ServletRequestDataBinder createBinder(HttpServletRequest request,
                                                ThrowawayController command)
                                         throws Exception
Create a new binder instance for the given command and request.

Called by bindAndValidate. Can be overridden to plug in custom ServletRequestDataBinder subclasses.

Default implementation creates a standard ServletRequestDataBinder, sets the specified MessageCodesResolver (if any), and invokes initBinder. Note that initBinder will not be invoked if you override this method!

Parameters:
request - current HTTP request
command - the command to bind onto
Returns:
the new binder instance
Throws:
Exception - in case of invalid state or arguments
See Also:
initBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.bind.ServletRequestDataBinder), getCommandName()

initBinder

protected void initBinder(HttpServletRequest request,
                          ServletRequestDataBinder binder)
                   throws Exception
Initialize the given binder instance, for example with custom editors. Called by createBinder.

This method allows you to register custom editors for certain fields of your command class. For instance, you will be able to transform Date objects into a String pattern and back, in order to allow your JavaBeans to have Date properties and still be able to set and display them in an HTML interface.

Default implementation is empty.

Parameters:
request - current HTTP request
binder - new binder instance
Throws:
Exception - in case of invalid state or arguments
See Also:
createBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.servlet.mvc.throwaway.ThrowawayController), DataBinder.registerCustomEditor(java.lang.Class, java.beans.PropertyEditor), CustomDateEditor

getLastModified

public long getLastModified(HttpServletRequest request,
                            Object handler)
This implementation always returns -1, as last-modified checks are not supported.

Specified by:
getLastModified in interface HandlerAdapter
Parameters:
request - current HTTP request
handler - handler to use
Returns:
the lastModified value for the given handler
See Also:
HttpServlet.getLastModified(javax.servlet.http.HttpServletRequest), LastModified.getLastModified(javax.servlet.http.HttpServletRequest)


Copyright (c) 2002-2006 The Spring Framework Project.