Hello,
I've decided to add validation into the "onSubmit" method without using validation interface:
...
if( dbUser == null ) {
// rejectValue(
String field, String errorCode, String defaultMessage);
// field - in
JSP file: <form:input path="name"/>
// errorCode - in "errors.properties" file: "user.name.invalid=User does not exist"
bindException.rejectValue("name", "user.name.invalid", "Incorrect Username.");
return showForm(request, response, bindException);
}
...
Here is my jsp:
<form:form method="POST" action="login.htm" commandName="user">
<b>Name: </b> <form:input path="name"/><br/>
<b>Password:</b> <form:input path="password"/><br/>
<input type="submit" name="submit" value="Sumbit"/>
</form:form>
For some reasone I cannot see the "Incorrect Username." message. When the case is applied, the form is displayed again, but without my default (the 3rd argument of rejectValue()). At the moment I don't use error.messages file.
It seems, that the "name" in the firsr argument of rejectValue() can not be mapped into <form:input path="name"/> on my jsp page.
Please help.