[stringtemplate-interest] Tree of objects
Peter Knego
peter at knego.net
Mon Jan 17 07:16:14 PST 2011
Hi,
I'm a newbie, so please bare with me. I read the docs and searched the
mailinglist but could not find an appropriate answer.
I have a tree of objects that represent a GUI hierarchy. Classes used
are children of either ViewGroup or View. ViewGroup is a parent of
View. ViewGroup is a container that holds a list other ViewGroups (and
Views, since they are children of ViewGroup). Views are edge nodes
that represent visual elements (buttons, etc..).
This object tree is built dynamically at run-time. The depth of the
tree can vary, usually it's 3-4 levels deep.
I'd like to use ST to create HTML based on the object tree. What
baffles me is how to support non-fixed depth of this tree, which
happens because ViewGroup can contain other ViewGroups.
Simplified example:
class Div{
public List<Div> subDivs;
}
Please suggest how this can be solved? Is there any example you can
point me to? I read that ST templates can be called recursively (for
handling ViewGroups containg itself), but how do I pass the right
object reference to it?
Thanks for your help,
Peter Knego
More information about the stringtemplate-interest
mailing list