You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Manav Gupta <Ma...@cramer.com> on 2003/10/06 18:41:37 UTC

retrieving values from multiple="true" select box

Hi,
 
I'm sure this has been resolved by a thousand ppl before me, but I'm unable
to find an answer to it. I did google, but I'm at a loss I'm afraid.
 
So here goes: I need to retrieve all selected values from a HTML select
object, that has "multiple=true" set.
 
Here's my form bean snippet:
=======
private final class TheFormBean {
 private String[] circuitTypeIDs;
 
  public  void setCircuitTypeIDs(String[] circuitTypeIDs)
  {
      this.circuitTypeIDs = circuitTypeIDs;
  }
 
  public  String[] getCircuitTypeIDs() {
   return this.circuitTypeIDs;
  }
}
 
  
The JSP:
=======
<html:select name="CircuitForm" property="circuitTypeIDs" multiple="true"
size="3" >
    <html:options collection="CircuitTypes" property="ID"
labelProperty="name"/> 
</html:select>
 
 
I do set the collection 'CircuitTypes' in the request in the action class
that forwards to the JSP above. 
The form-bea 'CircuitForm' has been declared in struts-config.xml (and I do
understand I don't need to mention the name of that form in the JSP).
 
However, when it retrieves only the *first* selected value in the select
box. What am I missing?
 
Deeply stressed,
M