Link to home
Start Free TrialLog in
Avatar of jaggernat
jaggernat

asked on

<html:select>

Dear experts

1)   I have this in my jsp

<html:select property="abc" multiple="multiple"/>
Values in this field are populated on page load which are coming from the database.

2)   I have this in my form bean

<form-bean name="Form" type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
<form-property name="abc" type="java.lang.String"/>
</form-bean>


My requirment:  I am selecting multiple values in my above <html:select> field
and i want to store all the values in an Array / ArrayList in my action class.

any ideas how i can approach on this
thanks
J
Avatar of fargo
fargo

you can use String[] for form property

<form-property name="abc" type="java.lang.String[]"/>

You can also set it to an ArrayList

<form property name="abc" type="java.util.ArrayList">
Avatar of jaggernat

ASKER

ok got it.

but how do i get the array/arraylist values in my action class?


public ActionForward getArrayValues(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
DynaValidatorForm f = (DynaValidatorForm) form;

f.????   //What do i do here to get all the values which user selected in the <html:select property="selectedvalues" multiple="multiple" width="40">  ?

return mapping.findForward("success");
}

any help greatly appreciated.

thanks
J
ArrayList abc = (ArrayList)f.get("abc")

ok thanks.
so is it possible to find out the values which user selected from this arraylist or array?
thanks

ASKER CERTIFIED SOLUTION
Avatar of Krule
Krule
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks