
|
If you were logged in you would be able to see more operations.
|
|
|
|
The code:
@Autowired(required = false)
@Qualifier("beanValidator")
Validator validator;
followed by
if (validator != null)
setValidator(validator);
}
in the constructor doesn't work. The field validator is always null when instantiating the bean, and the validator field is set after instatiating the object but then it is to late.
Solution:
Add this method
@Autowired(required = false)
public void setFormValidator(Validator validator) {
if (validator != null) {
setValidator(validator);
}
}
and remove the code from the constructor and it should work properly again.
|
|
Description
|
The code:
@Autowired(required = false)
@Qualifier("beanValidator")
Validator validator;
followed by
if (validator != null)
setValidator(validator);
}
in the constructor doesn't work. The field validator is always null when instantiating the bean, and the validator field is set after instatiating the object but then it is to late.
Solution:
Add this method
@Autowired(required = false)
public void setFormValidator(Validator validator) {
if (validator != null) {
setValidator(validator);
}
}
and remove the code from the constructor and it should work properly again.
|
Show » |
|
http://source.appfuse.org/browse/appfuse-light/trunk/src/main/java/org/appfuse/web/UserFormController.java?r1=141&r2=142
Notice the following in onSubmit():
// validation, TODO: Figure out how to do automatically
validator.validate(command, errors);
if (errors.getErrorCount() > 0)
return showForm(request, response, errors);
I like your solution better.