Would it be possible to have multiple initBinder Methods inside a single Controller? Where each InitBinder() (see code) depends on a unique request handler e.g. initBinder() is called on url: "/update/account" and initBinderOne() on "update/account/pass"?
I would prefer to have a single Controller for all updates instead of multiple. Please advise.
@Controller
@RequestMapping(value="/uodate/account")
public class UpdateController {
@RequestMapping(method=RequestMethod.GET)
public String updateAccount(@ModelAttribute("account") Account account...){
..
}
@RequestMapping(method=RequestMethod.POST)
public String update(@Valid Account account...){
...
}
@RequestMapping(value="/pass", method=RequestMethod.GET)
public String updatePass(@ModelAttribute("account") Account account...){
...
}
@RequestMapping(value="/pass",method=RequestMethod.POST)
public String updatePass(@Valid Account account...){
...
}
@InitBinder("account")
public void initBinder(WebDataBinder binder){
binder.setValidator(validateAccount);
binder.setAllowedFields(new String[]{"accountId","accountname","firstName",
"lastName","address"});
}
@InitBinder("account")
public void initBinderOne(WebDataBinder binder){
binder.setValidator(validatePassword);
binder.setAllowedFields(new String[]{"accountId","password});
}