aspose file tools
The moose likes Spring and the fly likes Spring, form validation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Spring
Reply Bookmark "Spring, form validation" Watch "Spring, form validation" New topic
Author

Spring, form validation

Alex Skv
Greenhorn

Joined: Apr 11, 2010
Posts: 1
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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Spring, form validation
 
Similar Threads
TOMCAT 7 - Jboss 5.1.0.GA - Spring - JSP - I need some guidance.
Validation error: Failed to convert property value of type [java.lang.String] to required type [int]
<form:hidden path="lastName" value="${param.lname}" /> is it valid ?
spring validation problem
How can I get a normal input tag's value?