Announcement Announcement Module
Collapse
No announcement yet.
AbstractCommandController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AbstractCommandController

    I am a newbie to Spring and trying to implement AbstractCommandController. code for this is as follows:

    public class MenuController extends AbstractCommandController
    {
    private ManualHandlerBPO manualHandlerBPO = null;

    public ManualHandlerBPO getManualHandlerBPO() {
    return manualHandlerBPO;
    }

    public void setManualHandlerBPO(ManualHandlerBPO manualHandlerBPO) {
    this.manualHandlerBPO = manualHandlerBPO;
    }

    public MenuController()
    {
    setCommandClass(ManualCommand.class);
    }

    protected ModelAndView handle(HttpServletRequest arg0, HttpServletResponse arg1, Object command, BindException arg3)
    throws Exception {

    ManualCommand manCommand = (ManualCommand)command;
    ManTO manTO = null;
    manTO.setId(manCommand.getId());
    long id = manTO.getId();
    manTO = (ManTO) manualHandlerBPO.process(manTO);

    return new ModelAndView("menu", "view", manTO);
    }
    }

    I have also added command refernc in .xml file as

    <bean id="MenuController" class="com.biomedcentral.export.mvc.MenuController ">
    <property name="manualHandlerBPO"><ref bean="ManualHandlerBPO"/></property>
    <property name="commandClass"><value>com.biomedcentral.expor t.mvc.ManualCommand</value></property>
    </bean>

    but command object is not getting initialized. am i mising anything?

    thanks in advance
    ---
    yogita

  • #2
    Can you expand a bit please

    Did you read the javadoc for the handle method which states
    * <p>Call <code>errors.getModel()</code> to populate the ModelAndView model
    * with the command and the Errors instance, under the specified command name,
    * as expected by the "spring:bind" tag.
    i.e. you need to do:
    Code:
      ModelAndView mav = new ModelAndView&#40;"menu", "view", manTO&#41;;
      mav.addAllObjects&#40;errors.getModel&#40;&#41;&#41;;
      return mav;

    Comment

    Working...
    X