> -----Original Message-----
> From: Mathieu Frenette [mailto:[EMAIL PROTECTED]]
> Sent: donderdag 17 januari 2002 15:13
> To: Struts-User (E-mail)
> Subject: Accessing a nested Collection within <html:options>
>
>
> Greetingz Struts fanatics! ;)
>
> The collection I want to use in my <html:options> is nested
> two levels deep
> from the bean that is actually in scope (named 'database').
> For example,
> here's how I'm accessing the collection from JSP scriplet:
>
> <% Collection users = database.getUsersTable().getUsers(); %>
>
> Each 'User' bean in the collection as an "id" and "username"
> property, which
> I want as key and label respectively, so I thought the
> following would work,
> but it doesn't:
>
> <html:select property="userId">
> <html:options
> collection="database.usersTable.users"
> property="id"
> labelProperty="username"/>
> </html:select>
>
> I get the following exception:
>
> javax.servlet.ServletException:
> Cannot find bean under name database.userstable.users
>
> Even if I put my getUsers() method directly in the database
> bean, I still
> get a message "... cannot find bean under name database.users".
>
> So my guess is that <html:options> doesn't support bean
> nesting (in the form
> of "bean1.bean2.bean3") as <logic:iterate> does... Is that right?
IIRC, logic:iterate also only supports this notation in the "property"
attribute, not in the name attribute (as all tags do)
> The only thing that worked (but wasn't pretty) was to put a
> scriptlet at the
> top of the page to take the nested users collection and put
> it directly as a
> request attribute, and then refer to it from the options tag.
You can also use the bean:define tag, that should do the trick in your
case:
<html:select property="userId">
<bean:define
id="coll"
name="database"
property="usersTable.users">
<html:options
collection="coll"
property="id"
labelProperty="username"/>
</bean:define>
</html:select>
hth,
tomK
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>