I want to iterate the selected values in another form. So, since I require ArrayList, i am having the below code in ActionForm.
But the Arraylist is always empty. Why is it so? If the above code is wrong, how do i do it?
Joined: Feb 15, 2005
First of all, when creating a group of checkboxes, it's better to use <html:multibox> rather than <html:checkbox>
Secondly, the expression:
does not return an ArrayList. It returns an unspecified implementor of the List interface. See for yourself in the Java API Docs
If you want to do it this way, try this:
this.permissions = new ArrayList(); this.permissions.addAll(Arrays.asList(permissions));
Thirdly, if you're going to represent the values internally as a List and externally as a String, that's fine, but both your getter and setter must treat it as a String. If you want to have a second getter and setter pair with a different name that treats it as a List, that's fine, but Struts expects the getter and setter for a property to be consistent in that they work with the same data type. [ August 13, 2006: Message edited by: Merrill Higginson ]