[stringtemplate-interest] Issues with handling refresh interval and group loaders.

Richard Martin bobthekingofegypt at googlemail.com
Tue Aug 26 09:03:09 PDT 2008


Hello,

I am using StringTemplate as my templating system, basically for
webpages, and over the development a couple of things have come up
that don't work the way I expected.  I am not sure if I have just used
them wrongly or not.

First is setting the refresh interval.  I want the refresh level to be
0 for all templates so I can just change the stg file and have all the
changes appear instantly on the site.  The templates basically follow
a simple inheritance design at the moment (but in my class that loads
the group I will not know this exact inheritance tree, base might or
might not exist in another context - I just give this as an example)
-

base - (page outline say)
sport extends base - (a page replacing regions in base)
news extends base - (a page replacing regions in base)

So the code rendering the page just calls loadgroup with news or sport
and then gets the instanceof page, sets the attributes and renders.
All works good but setting refresh interval to 0 only allows changes
in "news" to work not it's hierarchy.  So any changes to "base" do not
appear.  Even if I call getSupergroup on the "news" and sets its
timeout to 0 I still cant get any changes made to "base" to appear.
If I explicitly load base and set its timeout to 0 then I can get it
to accept changes.  But I will not know the specific hierarchies to
load in all super groups manually and set there timeouts.  Is this a
bug or a feature I am not using correctly, is it possible to set an
entire hierarchy refresh interval to 0?

Second is a feature I am probably not using the way that was expected.
 Basically my system is a web framework, it handles multiple contexts
and each context has it's own templates.  To try get around naming
conflicts what I did was cache a group loader for each context.  Then
when my string template controller is asked to render it registers the
group loader for that context with
StringTemplateGroup.registerGroupLoader().  Then it calls load group
with the correct template.  The problem here is if you have two
contexts that both have a base.stg for example.  Once you goto the
first context and render is called everything works fine, you get the
templates for that context.  Then you goto another context that has a
base.stg, the correct group loader is registered and the group is
loaded from it.  The problem there is you get the base.stg from the
first context even though you are on a different group loader, but if
the other templates don't clash by name you get the correct other
parts.  I am guessing that this is an artifact of the caching problem
above.  Base has been cached regardless of the registered group
loader.  So even though I have changed the group loader the call for
base.stg is returning the cached version.
Has it ever been considered that you might need a way to load multiple
distinct sets of templates (that may contain naming conflicts), or is
there another way to work around it?

Thanks for any help
Bob


More information about the stringtemplate-interest mailing list