Hi Samuel,

letīs suppose in your form you have the method getArrayListValues() returning the 
ArrayList containing the values and the method getArrayListLabels() returning the 
ArrayList containing the values for each option you wanna render. Then:

<html:form action="data" focus="identification">
<html:text property="identification"/>
<html:select property="selectedItem"> <!-- selectedItem must be a single-valued 
property -->
<html:options property="arrayListValues" labelProperty="arrayListLabels"/>
</html:select>
</html:form>

I think it will work, but you can try this too: (Iīm not sure it works)

struts-config.xml
<form-bean name="myForm" type="my.pkg.MyForm"/>

in MyForm there is a method (getValuesAndLabels()) returning a collection containing 
beans holding the label (getLabel()) and value (getValue()) for each option. Then:

<html:options collection="myForm.valuesAndLabels" property="value" 
labelProperty="label" />, or maybe:
<html-el:options collection="${myForm.valuesAndLabels}" property="value" 
labelProperty="label">

Just thoughts,

Henrique Viecili



  ----- Original Message ----- 
  From: Samuel Rochas 
  To: Struts Users Mailing List 
  Sent: Thursday, May 27, 2004 6:58 PM
  Subject: <html:options> only with bean?


  Hello there,

  I am able to create a html select with struts when the collection to 
  display in the options tag is a collection stored in the session or 
  request and to use the selected value for my form. Fine.

  But now I have a Form representing a bean. This form has an attribute of 
  type ArrayList. I'd like the select/options tag to show me the content 
  of the ArrayList for the actual Form property value. I want to use the 
  form attribute and not create a collection to store in a scope.

  My JSP looks like:
  <html:form action="data" focus="identification">
  <html:text property="identification"/>
  <html:select property="selectedItems">
  <html:options collections="allItems"
  property="id" labelProperty="description"/>
  </html:select>

  My form DataForm has the attributes identification, selectedItems and 
  allItems.

  But it is not working. Anybody a hint?

  Sincerly
  Samuel

  ---  andinasoft SA - Software y Consulting  ---
  Mariano Aguilera 276 y Almagro - Quito, Ecuador
  Tel. +593 2 290 55 18 ---- Cel. +593 9 946 4046
  ---------  http://www.andinasoft.com  ---------


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

Reply via email to