You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Kelvin Tan <ke...@relevanz.com> on 2001/05/25 06:31:03 UTC

#foreach loops and attribute names

Hi,

I'm experiencing difficulty getting Attribute names to be displayed when I
use $variable.AttributeName.

I've a vector of objects which I add to the context. Each object has private
String attributes and there are getter and setter methods for each attribute
in the object.

There's nothing wrong with my template code or the vector I add to the
context because when I do

#foreach ($product in $allProducts)
$product
#end

it spews out a list of my Product object references (Product@F4453D).

But when I try

#foreach ($product in $allProducts)
$product.Attribute
#end
it does not retrieve the attribute but displays $product.Attribute as a
String literal instead.

Can anyone help here?

Sincerely,
Kelvin Tan

Relevanz Pte Ltd
180B Bencoolen St.
The Bencoolen, #04-01
S(189648)

Tel: 238-6229