#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Sacramento
    Posts
    3
    Rep Power
    0

    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. #2
  3. dont click here
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    409
    Rep Power
    13
    i would create a vector call property Id and manipulate that. It would be a whole lot easier
  4. #3
  5. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    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

IMN logo majestic logo threadwatch logo seochat tools logo