I am new to annotated controllers and i have a problem. Ive heard it is possible to navigate between forms using them, but cant achieve that.
Well probably I could use SWF but for whole project controllers are more suitable.
My controllers looks like this:
@Controller
public class AnDBChooseController {
@RequestMapping("/dbchoose")
public ModelAndView choose(@ModelAttribute("db") ComponentDB db){
ModelAndView mv=new ModelAndView();
switch(db.getDbAction()){
case 1: // dodanie komponentu
if (db.getDbType().equals(ComponentDB.DB_CAPACITOR)){
mv.addObject("capacitor",new Capacitor());
mv.setViewName("addcapacitor");
}else if (db.getDbType().equals(ComponentDB.DB_RESISTOR)){
mv.setViewName("addresistor");
}
break;
case 2: // future
break;
case 3: // future
break;
default: // future
break;
}
return mv;
}
}
This controller should send me to addcapacitor.jsp
Secound controller (witch never starts)
@Controller
public class AnAddCapacitorController {
ComponentParamTypeService paramService;
@ModelAttribute("subclass")
public ArrayList<ComponentParamType> getSubclasses(){
System.out.println("I am here :]");
return paramService.getParamsForType(ComponentParamType.SUBCLASS_CAPACITOR);
}
@RequestMapping("/addcapacitor")
public String add(@RequestParam("capacitor")Capacitor capacitor){
return "addcapacitordetails";
}
public ComponentParamTypeService getParamService() {
return paramService;
}
public void setParamService(ComponentParamTypeService paramService) {
this.paramService = paramService;
}
}
Of course "I am here :]" never shows on console :(
How should change that so i am redirected to addcapacitor whitout loosing model parameters
Tahnks,