Hello Gautam,
I had the same problem, rendering an UI model as HTML(plain HTML or
JavaScript/HTML).
My solution is to have a directive called #function(name param1 param2
...) and the function is actually an abstractization,* *you can have a
function implemented in Java or can be another template(even a different
engine). The function implementation can specify if the context changes
propagates or are local to the function(by default are local and this
should be the way to go) . I can mix different template engines, for
example I can call a FreeMarker template from my Velocity template ;)
I didn't had time to do some performance testing, but I don't think
there will be performance penalties and the memory consumption will be
the same as loading all 50 templates in memory.
I can send you the link to the source code if you want to have a look.
Gautam Joshi (jgautam) wrote:
Hi,
I am planning to use Velocity for a metadata driven UI framework.
A velocity template at will be fed the UI metadata from the database.
Based on this metadata,
this template will then invoke other velocity templates. I plan to have
templates defined for Text fields, Select Boxes, etc.
Based on the type and number of fields defined in the metadata, the
topmost velocity template in turn will call these other templates that
handle specific field types.
I do not expect the metadata to have more than 50 fields.
Do you think this approach will cause any memory or performance issues?
I would really appreciate if someone could share their thoughts and
prior experiences.
Thanks
-Gautam