struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Bednarz <l...@bednarz.ch>
Subject Re: How to set the property of a drop-down select list from an action class?
Date Thu, 07 Sep 2006 10:12:56 GMT
Hi Puneet,

Thanks for your input. The problem seems only to exist when using 
declarative programming in the struts-config.xml file using 
DynaValidatorActionForm. I now coded my onwn form class derived from 
ValidatorActionForm and everything works just fine with my datastructures.

Tom

Puneet Lakhina wrote:
> On 9/4/06, Tom Bednarz <list@bednarz.ch> wrote:
>>
>> Hi Martin,
>>
>> Hmm, thanks for the link.
>>
>> Finally my problem is, that in the generated HTML page NONE of the
>> option tags has the attribute SELECTED. So my drop-down list box
>> displays the whole collection as expected, but setPropertyUtils seems to
>> have no impact otherwise the correct value should be selected.
>>
>> So probably could someone post the code for a simple problem:
>>
>> I have a select box eg
>>
>> 0 Value0
>> 1 Value1
>> 2 Value2
>>
>> Displayed to the user is
>> Value0
>> Value1
>> Value2
>>
>> If a specific record is looked at, the Value might be 1, so I should set
>> the property to 1 and the list-box should show
>> Value1 to the user as selected item.
>>
>> This should be a very common problem but I simply cant get it working!!!
>>
>> Tom
>>
> AFAIK this is done in the following way
>
> <html:select property="foo">
> <html:options collection="someCollection" property="someProperty"
> labelProperty="someLabelProperty" />
> </html:select>
>
> Now the value that will be selected will be the one whose value attribute
> equals the property specified in <html:select>.
> i.e. suppose when the page is loaded the property foo has value "NYC" 
> then
> the object in the options collection whose someProperty equals "NYC" 
> will be
> selected.
>
> So I think what you ought to have in order for the right value to be
> selected is
>
> <html:select property="expenseType.typeCode">
> <html:options collections="expenseTypes" property="typeCode"
> labelProperty="typeDescription" />
> </html:select>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message