Results 1 to 2 of 2

Thread: AbstractCommandController

  1. #1
    Join Date
    Sep 2005
    Location
    uk
    Posts
    8

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    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;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •