Aha!

i use the bean:write's but then i like doing things the complicated way.
Never used the html:options in this situation before so thanks for the tip -
will make things much easier!

cw :)


----- Original Message -----
From: "Mark Lowe" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Monday, February 02, 2004 12:34 PM
Subject: Re: AW: html:options and html:select


Thank goodness for that, dunno why folks seem to do that bean:write for
dropdowns :o)



On 2 Feb 2004, at 13:27, Otto, Frank wrote:

> Thanks for your answer, but
>
> I have found out, that I can use html:optionsCollection.
>
> <html:select property="ref">
> <html:optionsCollections name="myForm" property="myListOfBean"
> value="id" label="name"/>
> </html:select>
>
> Regards,
>
> Frank
>
> -----Ursprüngliche Nachricht-----
> Von: Claire Wall [mailto:[EMAIL PROTECTED]
> Gesendet: Montag, 2. Februar 2004 13:22
> An: Struts Users Mailing List
> Betreff: Re: html:options and html:select
>
>
> you can do the following:
>
> <html:select name="FormName" property="xxx">
>     <logic:iterate id="product" name="FormName" property="ListName">
>         <option value="<bean:write name="product"
> property="id"/>"><bean:write name="product" property="name"/>
>     </logic:iterate>
> </html:select>
>
>
> 'property' of the select box should be the name of the property in your
> FormBean that you wish to store the selected value in.
> You then iterate through the list in your form by using the
> <logic:iterate>
> tag. For every object in your list an <option> tag is written, where
> the
> value is the property 'id' of the current CProduct and the name
> displayed in
> the select box is the name of this CProduc object. This may not work
> as it
> stands due to using an Integer object - i'm not certain that you can
> set the
> value of a select box option to an Integer object. You'd have to try
> it and
> see, and perhaps somebody can clarify this further, but I've never
> tried
> this myself.
>
> HTH
> claire :)
>
> ----- Original Message -----
> From: "Otto, Frank" <[EMAIL PROTECTED]>
> To: "Struts-User (E-Mail)" <[EMAIL PROTECTED]>
> Sent: Monday, February 02, 2004 12:11 PM
> Subject: html:options and html:select
>
>
>> hello,
>>
>> I have following bean:
>>
>> public class CProduct {
>>
>>     private Integer id;
>>
>>     private String name
>>
>>     public Integer getId() {return id;}
>>     puclic void setId(Integer id){
>> ...
>> }
>>
>> My form class contains a java.util.List of CProduct bean.
>>
>> How can I display the List as select box? I want to use the id as
>> value
> and the name as label of the select box.
>>
>> For example:
>>
>> <select name="ref">
>>     <option value="1">scanner</option>
>>     <option value="2">harddisk</option>
>> </select>
>>
>> Has anyone an idea?
>>
>> Regards,
>>
>> Frank
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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






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

Reply via email to