[stringtemplate-interest] Newby question on lists

Wolfgang Ponikwar woponikwar at ib-ponikwar.de
Fri Sep 5 08:14:23 PDT 2008


Hi,

I have just started with StringTemplate, so my question might be very 
simple. I have tried to figure out how to access a Java List as an 
attribute of a class. The situation seems simple:
I have two classes, Foo and Bar, where Foo holds a list of Bars and Bar 
holds another list of X.
class Foo {
 List<Bar> bars;
...
}
class Bar {
 List<X> members;
...
}

I pass my Object foo to StringTemplate using setAttribute(...), 
resulting in the contained Bar instances being flattened and applied to 
the template. That works nicely. When I then pass one Bar instance 
inside this template to another template from a separate file and 
attempt to access any of the X members like:
$it.members:template()$
I get no output. Testing multivalued nature using
$length(it.members)$
gives me 1 for the singular List instance.
I was expecting to get the number of elements in the list, just as if I 
had passed the list to the template via setAttribute(...).
I must admit, I am quite confused, especialy, since I could not find a 
single working example.
I have been browsing the list archive, but my question must be so simple 
that I did not find any thread on this subject.
I gues, I must be making a stupid mistake?

Any help really apreciated.

Kind regards,

-- 
Wolfgang Ponikwar



More information about the stringtemplate-interest mailing list