• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not able to display error message using spring validator

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic