Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping list to type

 
Dompuk Kogepan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic