|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--com.interface21.context.support.ApplicationObjectSupport
|
+--com.interface21.web.servlet.mvc.WebContentGenerator
|
+--com.interface21.web.servlet.mvc.multiaction.MultiActionController
Controller implementation that allows multiple request types
to be handled by the same class.
Subclasses of this class can handle several different types of request
with methods of the form
ModelAndView actionName(HttpServletRequest request, HttpServletResponse response);
May take a third parameter HttpSession in which an existing session will be required,
or a third parameter of an arbitrary class that gets treated as command
(i.e. an instance of the class gets created, and request parameters get bound to it)
These methods can throw any kind of exception, but should only let propagate
those that they consider fatal, or which their class or superclass is prepared to
catch by implementing an exception handler.
This model allows for rapid coding, but loses the advantage of compile-time
checking.
Inherits superclass bean properties. Adds methodNameResolver bean property.
An implementation of the MethodNameResolver interface defined in this package
should return a method name for a given request, based on any aspect of the request,
such as its URL or an "action" or like attribute. The default behavior is URL based.
Also supports delegation to another object.
Subclasses can implement custom exception handler methods with names such as
ModelAndView anyMeaningfulName(HttpServletRequest request, HttpServletResponse response, ExceptionClass exception);
The third parameter can be any subclass or Exception or RuntimeException.
There can also be an optional lastModified method for handlers, of signature
long anyMeaningfulNameLastModified(HttpServletRequest request)
If such a method is present, it will be invoked. Default return from getLastModified()
is -1, meaning that content must always be regenerated.
Like Struts 1.1 DispatchAction, but more sophisticated.
The mapping from requests to handler method names is parameterized in the MethodNameResolver
interface.
Note that method overloading isn't allowed.
| Field Summary | |
static java.lang.String |
LAST_MODIFIED_METHOD_SUFFIX
Prefix for last modified methods |
| Fields inherited from class com.interface21.context.support.ApplicationObjectSupport |
logger |
| Constructor Summary | |
MultiActionController()
Constructor for MultiActionController that looks for handler methods in the present subclass. |
|
MultiActionController(java.lang.Object delegate)
Constructor for MultiActionController that looks for handler methods in delegate, rather than a subclass of this class. |
|
| Method Summary | |
protected void |
bind(javax.servlet.ServletRequest request,
java.lang.Object command)
Bind request parameters onto the given command bean |
protected java.lang.reflect.Method |
getExceptionHandler(java.lang.Throwable exception)
Can return null if not found |
long |
getLastModified(javax.servlet.http.HttpServletRequest request)
Try to find an XXXXLastModified method, where XXXX is the name of a handler. |
MethodNameResolver |
getMethodNameResolver()
Get the MethodNameResolver used by this class |
ModelAndView |
handleRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Process the request and return a ModelAndView object which the DispatcherServlet will render. |
protected ModelAndView |
invokeNamedMethod(java.lang.String method,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Invoke the named method. |
protected java.lang.Object |
newCommandObject(java.lang.Class clazz)
Create a new command object of the given class. |
void |
setDelegate(java.lang.Object delegate)
Set the delegate used by this class. |
void |
setMethodNameResolver(MethodNameResolver methodNameResolver)
Sets the method name resolver used by this class. |
| Methods inherited from class com.interface21.web.servlet.mvc.WebContentGenerator |
cacheForSeconds, preventCaching, setUseExpiresHeader |
| Methods inherited from class com.interface21.context.support.ApplicationObjectSupport |
getApplicationContext, initApplicationContext, setApplicationContext |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String LAST_MODIFIED_METHOD_SUFFIX
| Constructor Detail |
public MultiActionController()
throws ApplicationContextException
ApplicationContextException - if the class doesn't contain any
action handler methods (and so could never handle any requests).
public MultiActionController(java.lang.Object delegate)
throws ApplicationContextException
delegate - handler class. This doesn't need to
implement any particular interface, as everything is done
using reflection.ApplicationContextException - if the class doesn't
contain any handler methods| Method Detail |
public final void setMethodNameResolver(MethodNameResolver methodNameResolver)
methodNameResolver - the method name resolver used by this classpublic final MethodNameResolver getMethodNameResolver()
public final void setDelegate(java.lang.Object delegate)
throws ApplicationContextException
delegate - class containing methods, which may
be the present class, the handler methods being in a subclassApplicationContextException - if there aren't
any valid request handling methods in the subclass.public final long getLastModified(javax.servlet.http.HttpServletRequest request)
getLastModified in interface LastModifiedLastModified.getLastModified(HttpServletRequest)
public final ModelAndView handleRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
ControllerhandleRequest in interface ControllerAbstractController.handleRequestInternal(HttpServletRequest, HttpServletResponse)
protected final ModelAndView invokeNamedMethod(java.lang.String method,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws NoSuchRequestHandlingMethodException,
javax.servlet.ServletException,
java.io.IOException
protected java.lang.Object newCommandObject(java.lang.Class clazz)
throws javax.servlet.ServletException
protected void bind(javax.servlet.ServletRequest request,
java.lang.Object command)
throws javax.servlet.ServletException
request - request from which parameters will be boundcommand - command object, that must be a JavaBeanprotected java.lang.reflect.Method getExceptionHandler(java.lang.Throwable exception)
exception - Won't be a ServletException or IOException
|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||