IntelliJ Java IDE
The moose likes Other Application Frameworks and the fly likes Not able to display error message using spring validator Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "Not able to display error message using spring validator" Watch "Not able to display error message using spring validator" New topic
Author

Not able to display error message using spring validator

Sharath yadav
Greenhorn

Joined: May 03, 2006
Posts: 1
Hi all,

I am working on a sample application using spring MVC.
Step 1.
I am displaying all product stock details.
and alsi link to "sell" the stock.
Step 2.
when i click on "sell" all the stocks realated to a perticular product will be displpayed. In this page i have a text box to enter quantity to sell the stock.

-> when i enter quantity greator than tha available quantity: i need to dispaly error message. Page is refreshing but error message is not displpayed on the page.

public void validate(Object obj, Errors errors) {
Product product = (Product) obj;
if (product == null) {
errors.rejectValue("order", "error.not-specified", null,
"Value required.");
}

if (product.getOrder() == 0) {
logger.info("Order value:::::" + product.getOrder());
errors.rejectValue("order", "error.not-specified", null,
"Value required.");

}
}

ANY IDEA?

regards
sharath
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1209

What code are using in the JSP to display the error messages?
You need to use Spring MVC form tags to get access to the error messages bound to the form backing object.


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
 
 
subject: Not able to display error message using spring validator
 
Threads others viewed
sentinal controlled looop
Not getting the validation message in my example.
Help wit h code
validation in spring
Illegal start of type; identifier expected problem.
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture