You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Dario Novakovic <da...@yahoo.com> on 2001/10/18 13:07:24 UTC

class in collection in context

i have got a simple bean(lots of them), and i put them
in ArrayList, then i put array list in context

context.put("lista",list);

template looks like this

#foreach ($zapis in $lista) 
	<tr>
		<td>$zapis.name</td>
		<td>$zapis.address</td>
	</tr>
#end


and it doesn't work. log file says that zapis.XXX is
not legal refernce. i also tried calling getters but i
got the same answer.

is it possible to call class method and properties
from a collection in context?


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

Re: class in collection in context

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 10/18/01 7:07 AM, "Dario Novakovic" <da...@yahoo.com> wrote:

> i have got a simple bean(lots of them), and i put them
> in ArrayList, then i put array list in context
> 
> context.put("lista",list);
> 
> template looks like this
> 
> #foreach ($zapis in $lista)
> <tr>
> <td>$zapis.name</td>
> <td>$zapis.address</td>
> </tr>
> #end
> 
> 
> and it doesn't work. log file says that zapis.XXX is
> not legal refernce. i also tried calling getters but i
> got the same answer.
> 
> is it possible to call class method and properties
> from a collection in context?

Of course.  You cannot access the member fields of a class, public or
private, ( ...pageng Lane Sharman...).

Just make sure that

1) getName() is public
2) getAddress() is public
3) your bean class is public

Geir

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.