[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-dev
Subject:    Re: Select tag (was: Bug report for Struts [2001/10/21])
From:       martin.cooper () tumbleweed ! com
Date:       2001-10-24 4:02:43
[Download RAW message or body]

Unless I'm misunderstanding you, the <html:select> tag works this way
already.

You can see this if you look at the struts-exercise-taglib.war application
bundled with Struts. It uses <html:select> in exactly the way you indicate -
with 'property' and without 'value' - and the initial selected value
corresponds to the value of the property.

You can also see this if you look at the code in SelectTag.doStartTag(),
where it says (abbreviating somewhat for clarity):

    if (value != null) {
        match = value;
    } else {
        Object bean = pageContext.findAttribute(name);
        match = BeanUtils.getSimpleProperty(bean, property);
    }

where 'match' is the value used to determine which item is initially
selected.

--
Martin Cooper


----- Original Message -----
From: "Joe Faith" <faith@runtime-collective.com>
To: <struts-dev@jakarta.apache.org>
Sent: Monday, October 22, 2001 1:29 AM
Subject: Re: Bug report for Struts [2001/10/21]


> bugzilla@apache.org wrote:
>
> | 4095|New|Nor|2001-10-11|html:select should take default value from the
> pro|
>
> I was planning to write a patch for this, but wanted to check the
> functionality with you guys first.
>
> The problem is that <html:select> fields don't inherit their default
> option from the corresponding form property. Unless you hard-code a
> default value (or use a jsp work-around) the select box defaults to the
> option at the top of the options list. The solution that fits most
> easily with existing struts functionality would be:
>
>
>     if 'property' tag attribute is set and 'value' isn't then set the
> html 'value' attribute to the current form property value.
>
>
> In other words, you can still override the current form property with a
> hard-code default option if you want to.
>
>
> The problem with this solution is that it is not *quite* backwards
> compatible: in particular, those pages that currently use a
> <html:select> without specifying a default value will find the option
> defaulting to the current property value, rather that the option at the
> top of the list.
>
>
> So is the current behaviour a bug that needs eliminating, or a
> much-loved 'feature' that needs preserving?
>
>
> --
>
>
> Joe Faith
>
>
> Runtime Collective, Ltd <http://www.runtime-collective.com>
> T: (+44) 01273 234294
>
>
>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic