hi,
I have 4 input pages, most of the fields on the pages are mandatory but they only need to be filled in and therefor only need to be validated when the user click a submit-button on another page.
What I would like to happen when the user clicks this button and several fields are not filled in is the following:
- navigate to the first input-page that has errors and display the field-errors using the <form:error>-tag.
- when the user then navigates to the next input-page do the same thing again
My theory on how to do this is is do the final validation in the onSubmit-method of the validate-controller (since I need to controll which ModelAndView to return), store the errors-object in the session and then in each controller for the input-pages check if this object exists in session and copy it to the request.
I have following (test)code in the validate-controller onSubmit-mehtod:
Code:ValidationUtils.rejectIfEmpty(errors, "sponsor", "error.field.required");if (errors.hasErrors()) { request.getSession().setAttribute("errors", errors);return new ModelAndView(new RedirectView("projectEditGeneral.htm")); }and this in one off the inputpage-controllers:Code:Object o = request.getSession().getAttribute("errors");if (o != null); request.setAttribute(BindingResult.MODEL_KEY_PREFIX + getCommandName(), o);but it doesn't work, maybe the key MODEL_KEY_PREFIX is not correct?
When debugging spring's ErrorTag it simply sais there are no errors so I guess setting this request-attribute did not follow through are is not enough. I don't realy know what's going on but I hope someone else does or can suggest a beter way to address this functional issue?
many thanks!


Reply With Quote