Results 1 to 2 of 2

Thread: Validating form with MultiActionController

  1. #1

    Default 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. #2

    Default

    Hi


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

    rather than spring:bing displaying the error messages.

Posting Permissions

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