Java Reference
In-Depth Information
To execute this modified workflow, I will need to map the request parameters to the
form bean in some component. You already know that the most appropriate component
for this is the handler adapter. Listing 3-40 shows the handler adapter that executes the
SimpleFormThrowaway controllers.
Listing 3-40. SimpleFormThrowawayControllerHandlerAdapter.java
package com.apress.insurance.web.handleradpter.api;
public class SimpleFormThrowawayControllerHandlerAdapter
extends ThrowawayControllerHandlerAdapter {
public boolean supports(Object handler) {
return (handler instanceof SimpleFormThrowawayController);
}
public ModelAndView handle(HttpServletRequest req, HttpServletResponse res,
Object command) throws Exception {
SimpleFormThrowawayController throwaway = (SimpleFormThrowawayController)
command;
Object formBean = throwaway.getFormbeanClass().newInstance();
ServletRequestDataBinder binder = createBinder(req, formBean);
binder.bind(req);
binder.closeNoCatch();
return throwaway.execute(formBean);
}
protected ServletRequestDataBinder createBinder(
HttpServletRequest request, Object formbean) throws Exception {
ServletRequestDataBinder binder = new ServletRequestDataBinder(formbean,
getCommandName());
initBinder(request, binder);
return binder;
}
}
Note that the createBinder method is responsible for binding the HTTP parameter
values to the properties of the form bean. The handler adapter takes care of all the
 
Search WWH ::




Custom Search