• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 815
  • Last Modified:

<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
0
jaggernat
Asked:
jaggernat
  • 3
  • 3
1 Solution
 
fargoCommented:
you can use String[] for form property

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

0
 
KruleCommented:
You can also set it to an ArrayList

<form property name="abc" type="java.util.ArrayList">
0
 
jaggernatAuthor Commented:
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
KruleCommented:
ArrayList abc = (ArrayList)f.get("abc")

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

0
 
KruleCommented:
That array WILL only contain the items that the user selected.
0
 
jaggernatAuthor Commented:
thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now