• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring, form validation

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic