Hello all,
I'm experiencing some strange behaviour with the AbstractWizardFormController (portlet version) with the validation of my first page.
Basically I have a wizard with 3 pages (pages 0,1 and 2). On submission of the page 0 a text field is checked to see if it has text by implementing the validatePage method in the wizard controller:Code:protected void validatePage(Object command, Errors errors, int page, boolean finish) { logger.info(quot;validatePage called for page quot; + page + quot; finish? quot; + finish); SearchAndReplaceValidator validator = (SearchAndReplaceValidator)getValidator(); switch (page) {
case 0:
validator.validatePage0(command, errors);
break;
case 1:
validator.validatePage1(command, errors);
break;
case 2:
validator.validatePage2(command, errors);
break; } }
The validatePage0(..) method gets called and rejects the value as expected:Code:
if(!StringUtils.hasText(command.getSearchText())) {
logger.info(quot;Rejecting search text: quot; + command.getSearchText());
errors.rejectValue(quot;searchTextquot;, quot;no.valuequot;, quot lease enter the search textquot;);
}
The problem is that although the errors object has the error - the postProcessPage method gets called anyway. Even when I check the Errors object in the postProcessPage it says it has an error but the controller seems to have proceeded anyway.
Whats wierd is that on the next page in the wizard (page 1) I have the same validation (different text field but same code). This time though, the page is redisplayed with the validation errors as expected.
Has anyone seen this before - I've never used the Servlet version but maybe it's the same?? I've just checked the sample application (BookAddController) which validates on the first page ok...
I'm using Spring 2.0-m4.
Thanks
Hmm. That's pretty strange. I don't necessarily see the problem.
One suggestion -- in your validate page, you are not checking the 'finish' flag and validating the entire object in that case.
Another suggestion -- sounds like you are running a milestone build from a pretty old version. Any reason not to update to at least 2.0.8? Going to 2.5.4 would be even better -- then you might want to use the annotation-based dispatching.
Anyway, if you are still having this problem after adding a method to validate the entire object and after updating to 2.0.8, then I would probably try to run in a debugger to figure out where the problem is creeping in. |