You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Lawlor, Frank" <Fr...@AthensGroup.com> on 2002/03/11 23:56:10 UTC

html:options bug?

The Struts Options tag seems to have problems accessing collections 
that are in some other object (e.g., your form).  The following dotted
notation should work (I thought) (roleList is an ArrayList):

   <html:select property="requiredrole">
        <html:options collection="MyForm.roleList" property="name"
labelProperty="description"/>
   </html:select>

or alternatively:

   <html:select property="requiredrole">
        <html:options name="MyForm" collection="roleList" property="name"
labelProperty="description"/>
   </html:select>

But both of these result in an error that a bean cannot be found in
roleList.
A workaround is to "cache" the list:

   <bean:define id="rolestemp" name="MyForm" property="roleList"
scope="session" />
   <html:select property="requiredrole">
        <html:options collection="rolestemp" property="name"
labelProperty="description"/>
   </html:select>

Is this a bug or expected behavior?

Frank Lawlor
Athens Group, Inc.
(512) 345-0600 x151
Athens Group, an employee-owned consulting firm integrating technology
strategy and software solutions.




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: html:options bug?

Posted by Arron Bates <ar...@pacific.net.au>.
The collection attribute needs the bean reference only. The dot notation 
is for your property. Because the collection isn't the bean itself 
you'll have to use a define tag or something to make a bean reference 
directly to your collection, then use that reference in your collection 
attribute.

For your second example... The collection attribute is overriding, and 
ignores the name attribute. It's meant to be the direct link to a bean 
reference that itself is a collection.

Arron.


Lawlor, Frank wrote:

>The Struts Options tag seems to have problems accessing collections 
>that are in some other object (e.g., your form).  The following dotted
>notation should work (I thought) (roleList is an ArrayList):
>
>   <html:select property="requiredrole">
>        <html:options collection="MyForm.roleList" property="name"
>labelProperty="description"/>
>   </html:select>
>
>or alternatively:
>
>   <html:select property="requiredrole">
>        <html:options name="MyForm" collection="roleList" property="name"
>labelProperty="description"/>
>   </html:select>
>
>But both of these result in an error that a bean cannot be found in
>roleList.
>A workaround is to "cache" the list:
>
>   <bean:define id="rolestemp" name="MyForm" property="roleList"
>scope="session" />
>   <html:select property="requiredrole">
>        <html:options collection="rolestemp" property="name"
>labelProperty="description"/>
>   </html:select>
>
>Is this a bug or expected behavior?
>
>Frank Lawlor
>Athens Group, Inc.
>(512) 345-0600 x151
>Athens Group, an employee-owned consulting firm integrating technology
>strategy and software solutions.
>
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>