December 28th, 2002, 02:59 PM
Any example code for multiple selected values from the list box to bean:
I have my form like:
<select name="propertyID" size=5 multiple>
<option value="1">some description 1</option>
<option value="2">some description 2</option>
<option value="3">some description 3</option>
<option value="4">some description 4</option>
<option value="5">some description 5</option>
in bean i have getter & setter methods:
now , how can i pass one or more selected values from the list box to the bean
and i have a query like:
strQuery = " select * from propery where propertyID IN(getPropertyID(), getPropertyID(), getPropertyID(),getPropertyID() , getPropertyID())"
I have to pass something like this:
select * from property where propertID IN(1,2,3,4)
now i have one getPropertyID() & setPropertyID() methods
how it is possible to pass same variable to pass the multiple values to the bean ?
Any sample code or example, greatly appreicated.
Thanks in advance.
December 28th, 2002, 04:18 PM
i would create a vector call property Id and manipulate that. It would be a whole lot easier
December 30th, 2002, 06:30 AM
The request object has a getParameterValues() method that returns an array of Strings. This is how you get form input with multiple values.
Unless having multiple propertyID values is going to be a rare case, I'd suggest you make your bean property a String. When you need to pass a single value, you can just pass a String (which you can get from request.getParameterValues() ).