Instead of a String[], try a List that is populated with label value beans
and use the indexed properties to access individual elements. 

<logic-el:iterate name="myList" property="foo" id="foo">
   <c:out value="${foo.description}"/>                   
    <html-el:select property="myField" indexed="true" name="foo">

       <html-el:optionsCollection name="theChoices"  />
    </html-el:select>
</logic-el:iterate> 

See http://jakarta.apache.org/struts/faqs/indexedprops.html for more details

-------- Original Message --------
Subject: how to get both values and text for <html:select/> option?
Date: Tue, 15 Jul 2003 14:21:50 -0400
From: Jung, Eric (Contractor) <[EMAIL PROTECTED]>
Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
Newsgroups: gmane.comp.jakarta.struts.user

Hi,
I've searched the FAQ and the archives, but can't find an answer to this
question. I'm know it's been asked before, but part of my problem seems to
be that the mail-archive search tool doesn't like colons or < > characters
(so searching for <html:select> becomes difficult). Try as I may, I'm not
able to find an answer.

I'm trying to get both the values and the text of the selected
<html:options/> in an <html:select/>. It appears that right now I'm only
getting one (the values, I think, but not the text) in my ActionForm's
String array:

  public class MappingForm extends ActionForm {
    private String [] columns;
    //getColumns() and setColumns() removed for brevity
    ...
  }

<html:select multiple="true" property="columns">
  <html:option value="a">one</html:option>
  <html:option value="b">two</html:option>
</html:select>

In other words, I'm only getting "a" and "b" in my array. However, I'd like
to have another String array, or a 2-dimensional String array, that receives
both "a", "one", and "b", "two".

Any help would be greatly appreciated. Thanks in advance.

Sincerely,

Eric H. Jung
Software Engineer
Russell/Mellon Analytical Services
1-617-382-1373
Everett, MA, USA
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to