Hi,
Im trying to understand what happens in the following case..
If I have a simple command object like the following..
My jsp page has the following formCode:class MyCommand { private int mMyCommandValue; public int getMyCommandValue() { return mMyCommandValue; } public void setMyCommandValue(int value) { mMyCommandValue = value; } }
And heres my validators validate method...Code:<form:form> <form:input path="myCommandValue"/> <input type="submit" value="submit/> </form:form>
Now in the examples It shows that you can further validate the command object by doing such things asCode:public void validate(Object object, Errors errors) { MyCommand myCommand = (MyCommand) object; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "myCommandValue", "error.required", "Required Field"); }
But what if i want to ensure that the user hasnt entered a character into the form field? Does the BeanWrapper set the commands value to null, or does it leave it as it is?Code:if (myCommand.getMyCommandValue() < 10) { errors.rejectValue("myCommandValue", "error.too_low", "Value too low"); }
How do i tell the user that they entered a non numeric value into the form?
Regards
Ben


Reply With Quote