You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andreas Leitner <al...@macron.at> on 2001/07/25 18:49:11 UTC

Accessing nested attributes using

Now, this may be a really stupid question and may not even fit this
list. If that's the case please give me a hint where I could look for an
answere.

I can render a property of a bean using <bean:write>, but what if I want
to render to a property, but a property of a property?

Imagine the class:
Person
	String name;
	Person father;

If I have a given person instance in a bean named "foo", I can render
it's name via
<bean:write name="bean" property="name"/>
But how can I render the name of foo's father?

Many thanks in advance,
Andreas


AW: Accessing nested attributes using

Posted by Andreas Leitner <al...@macron.at>.

> -----Ursprüngliche Nachricht-----
> Von: David Winterfeldt [mailto:dwinterfeldt@yahoo.com] 
> Gesendet: Mittwoch, 25. Juli 2001 22:57
> An: struts-user@jakarta.apache.org
> Betreff: Re: Accessing nested attributes using <bean:write>
> 
> 
> This is the same as getFather().getName().  You can
> also use nested properties for html:text and all the
> other Struts tags.
> 
> <bean:write name="bean" property="father.name"/>
> 
> Arrays are supported to.
> <bean:write name="bean" property="name[0]"/>

Silly me, I tried that of course as it seemed obvious. But I got an
error, now I discovered that the error was related to another class.
Unfortunatly the error told me "No Such Method" - given that it was late
already yesterday, I must have confused things.

Thanks for your help,
Andreas
PS: Also thanks to the other ppl. that responded.


Re: Accessing nested attributes using

Posted by David Winterfeldt <dw...@yahoo.com>.
This is the same as getFather().getName().  You can
also use nested properties for html:text and all the
other Struts tags.

<bean:write name="bean" property="father.name"/>

Arrays are supported to.
<bean:write name="bean" property="name[0]"/>

David

--- Andreas Leitner <al...@macron.at> wrote:
> 
> Now, this may be a really stupid question and may
> not even fit this
> list. If that's the case please give me a hint where
> I could look for an
> answere.
> 
> I can render a property of a bean using
> <bean:write>, but what if I want
> to render to a property, but a property of a
> property?
> 
> Imagine the class:
> Person
> 	String name;
> 	Person father;
> 
> If I have a given person instance in a bean named
> "foo", I can render
> it's name via
> <bean:write name="bean" property="name"/>
> But how can I render the name of foo's father?
> 
> Many thanks in advance,
> Andreas
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/