On 9/4/06, Tom Bednarz <[EMAIL PROTECTED]> 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> -- Puneet