Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Problem using Spring bind

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Spring to handle an update form with multiple rows.
The form jsp displays multiple lines of a format like this:
CustomerID PriceList Month Amount

...where amount is an input text box.
Since Spring allows POJOs as the command objects, I was assigning the results of this form to a Java.util.List. Unfortunately, when it came to to display validation errors in the Jsp, I found I could not figure out how to directly bind to any field that incurred an error (say, numeric format)- THey are all unnamed fields in a List!
Do I need to start over or is there a good way of handling multiple input fields in a Spring form?
(FYI- using a SimpleFormController with validations happening in onBindAndValidate)
 
Elie Hirschman
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Update:
I have tried to implement the suggestions from this blog:
Guide to Porting Struts to Spring
but to no real advantage.
 
Elie Hirschman
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to this had to do with creating a list in the command object to handle all the fields.
Each field had to be named, and named dynamically, as there was no way to know how many input boxes were going to be displayed as a result of the query. So here is what was done:
 
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
Thanks for sharing the solution, Elie. Cheers.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic