|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.servlet.mvc.throwaway.ThrowawayControllerHandlerAdapter
public class ThrowawayControllerHandlerAdapter
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.
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 |
---|
public static final String DEFAULT_COMMAND_NAME
Constructor Detail |
---|
public ThrowawayControllerHandlerAdapter()
Method Detail |
---|
public final void setCommandName(String commandName)
public final String getCommandName()
public boolean supports(Object handler)
HandlerAdapter
A typical implementation:
return (handler instanceof MyHandler);
supports
in interface HandlerAdapter
handler
- handler object to check
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
execute
on it.
handle
in interface HandlerAdapter
request
- current HTTP requestresponse
- current HTTP responsehandler
- handler to use. This object must have previously been passed
to the supports
method of this interface, which must have
returned true
.
null
if the request has been handled directly
Exception
- in case of errorscreateBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.servlet.mvc.throwaway.ThrowawayController)
,
ThrowawayController.execute()
protected ServletRequestDataBinder createBinder(HttpServletRequest request, ThrowawayController command) throws Exception
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!
request
- current HTTP requestcommand
- the command to bind onto
Exception
- in case of invalid state or argumentsinitBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.bind.ServletRequestDataBinder)
,
getCommandName()
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception
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.
request
- current HTTP requestbinder
- new binder instance
Exception
- in case of invalid state or argumentscreateBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.servlet.mvc.throwaway.ThrowawayController)
,
DataBinder.registerCustomEditor(java.lang.Class, java.beans.PropertyEditor)
,
CustomDateEditor
public long getLastModified(HttpServletRequest request, Object handler)
getLastModified
in interface HandlerAdapter
request
- current HTTP requesthandler
- handler to use
HttpServlet.getLastModified(javax.servlet.http.HttpServletRequest)
,
LastModified.getLastModified(javax.servlet.http.HttpServletRequest)
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |