• 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

Mapping list to type

 
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 have made a jsp-page, contaning two muliplte selection lists.
One of them is pre-populated with entries from the beginning, the other is empty. With a java-script i can move the entries from one list to the other.

Now, to my problem:
When i hit submit, i would like to save all the entries in the list that was empty from the beginning.

I have mapped the form against a POJO in the following way:
<form-bean name="listaForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="lista" type="mypackage.Lista" />
</form-bean>

Can I map the list directly against an list-type? Eg. ArrayList in the POJO? Or how can i do it in another way?

Please help, i will be eternally greatful for any answer
/Dompuk
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, struts won't map selected options in an <html:select> control directly to a List. You must use a String array for this. (type = java.lang.String[]) If you want to transfer the String array to a list, you'll have to write code to do that yourself once Struts has populated the String array.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written java script that will select all the items in the "selected" list box and then submit the form. This way the values get submitted with the form. I could try to track down an example if you have trouble getting the JSP to work.

- Brent
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic