• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Wrapped list in command object

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a list of input fields with a checkbox and label in front of every input field. The label titles are filled using a list of string values from the model. My command object contains a list of objects, with each object contining fields that map to checkbox, label and input. My problem is that i cannot manage to map these values to my command object. Below is the code that i have so far.




FieldsNames is a list of String objects added by the controller to the model.
When running above code i receive the error message that class MyCommand does not contain a property 'checked' upon submitting form, which is ofcourse true, but then again, i do not see how to map the above tags to the properties of class Field instead of class MyCommand which is the actual command object. Any help is appreciated.

Btw. the controller code is ommited due to the fact that it is out of scope for the problem i am facing.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ANd it really isn't a Spring issue either, sort of.

I mean how are you going to loop through the fields in the MyCommand object to actually set the values in the form. Unless this form is for create only and not edit.

But also, this is a classic One to Many problem, which I myself am trying to figure out on the web layer side.

Mark
 
Art Vandelay
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:ANd it really isn't a Spring issue either, sort of.

I mean how are you going to loop through the fields in the MyCommand object to actually set the values in the form. Unless this form is for create only and not edit.

But also, this is a classic One to Many problem, which I myself am trying to figure out on the web layer side.

Mark


Thanks for your reply.

This is indeed a form that will be used to enter data, so i do have to loop through the list of objects in MyCommand object so set the entered values.

Could you please elaborate a bit more on what you mean with a classical one to many problem and what you mean with solving the issue on the web layer. Or give a small example of you would solve this issue. Thanks.


Btw. i posted this in the Spring section, due to the fact that i am using Spring MVC and the spring form taglib, therefore i thought that the problem might an incorrect use of the form taglib.
reply
    Bookmark Topic Watch Topic
  • New Topic