|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Any example code for multiple selected values from the list box to bean:
I have my form like:
<form> <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> </select> Submit </form> 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. |
|
#2
|
||||
|
||||
|
i would create a vector call property Id and manipulate that. It would be a whole lot easier
|
|
#3
|
|||
|
|||
|
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[1] (which you can get from request.getParameterValues() ).
__________________
-james |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Any example code for multiple selected values from the list box to bean: |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|