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

  • Validating form with MultiActionController

    public class ExtendedMultiActionController extends MultiActionController{


    protected void bind(HttpServletRequest request, Object command) throws
    Exception{
    System.out.println("Aha i am here...");
    ServletRequestDataBinder binder = createBinder(request, command);
    Validator validators[] = getValidators();
    binder.bind(request);
    if (validators != null) {
    System.out.println("validators Length: "+validators.length);

    for (int i = 0; i < validators.length; i++) {
    if (validators[i].supports(command.getClass()))
    System.out.println("Supported.");
    ValidationUtils.invokeValidator(validators[i], command,
    binder.getErrors());
    binder.closeNoCatch();
    }
    }
    onBindAndValidate((HttpServletRequest)request, command,
    binder.getErrors());
    }
    protected void onBindAndValidate(HttpServletRequest request,
    Object command, BindException errors) throws Exception {
    // empty default implementation

    }

    }



    ************************************************** ***
    public class EditUserFormController extends ExtendedMultiActionController{

    public ModelAndView editUser(HttpServletRequest request,
    HttpServletResponse response,
    Object obj) throws ServletException, Exception {
    // code here

    }

    public ModelAndView saveUser(HttpServletRequest request,
    HttpServletResponse response,
    Object obj) throws ServletException, Exception {
    /*
    * Writing code here to make User Persistant
    *
    */

    ModelAndView mav=new ModelAndView("addUserSuccess");
    EditUser eUser = new EditUser();
    Validator[] v = {new EditUserFormValidator()};
    setValidators(v);
    bind(request, eUser);

    return mav;
    }


    }

  • #2
    Hi


    I have tried the following code ,but i get error messages thrwon to broswer .

    rather than spring:bing displaying the error messages.

    Comment

    Working...
    X