wood burning stoves 2.0*
The moose likes Struts and the fly likes Mapping list to type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Mapping list to type" Watch "Mapping list to type" New topic
Author

Mapping list to type

Dompuk Kogepan
Greenhorn

Joined: Apr 03, 2006
Posts: 1
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


Sometimes, but not always
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mapping list to type