struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Puneet Lakhina" <>
Subject Re: How to select a value when a form is prepopulated
Date Mon, 21 Aug 2006 05:08:09 GMT
On 8/21/06, sheetal <> wrote:

> Hi,
> My action class on success, is prepopulating a combo box (<select>..
> <option>...>, on the jsp..
> for which I have used a form bean.
> Now, the problem is that I also want a field to be selected from combo,
> after prepopulating it..
> and before displaying the jsp page...
> If anyone has any idea,..
> Thanks..
> Rgds,
> Sheetal

You could specify the value attribute in the select tag. This will be
matched with the value of the options element. If a match occurs that value
will be selected. In case a match does not occur, first options element will
be selected.

Please not the value and the label are two different things.

for e.g.
<select value="1">label</select>

Here is an example using <html:options>

<html:select property="foo" value="valueToSelect">
<html:options collection="someCollection" property="foo"
labelProperty="title" />

So in the above example someCollection.get(index).getFoo() will be comapred
with valueToSelect
someCollection.get(index).getTitle() will be used for making the label.

Hope this helps.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message