This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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.
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.