Hi all,
I am in the process of adding templating services to JBoss for my own
project, and figured it might be usefull to others.
Anyone have any desires for having WebMacro and/or Velocity templating
services in JBoss? I personally don't like JSP pages, and find them evil
when put to real production use (where you have Web-Monkies doing the HTML,
and programmers doing the Java. Web-Monkies don't do well if the template
logic needs to be coded in Java)
The other issue is, I don't know what the policies are for using third party
Open Source software in JBoss.
Assuming this is a desirable feature, and a viable one in regards to using
other projects software, here's my idea.
You start off by registering a "key" with a template path, ie:
admin = /var/templates/admin:/var/templates/shared
user = /var/templates/user:/var/templates/shared
The path's are just search paths for finding templates (similar to class
paths)
Then you'd have either:
WM WebMacroService.getEngine("admin")
That would return a "WM" object (A webmacro template engine)
Or
VelocityEngine VelocityService.getEngine("admin")
to get the velocity version using the same path.
I Don't really like that approach, since it allows people to much with the
engine directly, thereby messing up other consumers of the engine (the
engines are thread safe, so you'd return the same instance to everyone).
Also, I'm pretty sure that it would be legal to return a non-serializable
object.
So, the way I'd do it would be:
TemplateEngine.mergeWebMacro(String pathKey, String templateName, Map
dataToMerge)
TemplateEngine.mergeVelocity(String pathKey, String templateName, Map
dataToMerge)
Or better yet:
TemplateEngine.merge(String pathKey, String templateName, Map data)
And auto-determin the template engine to use (WebMacro prefers .wm, and
Velocity has some other extensions (I don't remember exactly which right
now))
A cooler way I suppose would be that when someone registers a key with a
path, we bind each engine to the JNDI tree as
template/webmacro/KEY
template/velocity/KEY
template/KEY
So the use can just get the correct node from the tree and
"merge(templateName, data)"
But, I'm not sure an MBean can tell how someone acquired a handle to it (so
it woudn't know which key to use).
So, if this seems like a reasonable thing to add, lemme know.
If you think I'm on crack, shut the hell up, I have to do it anyway for my
project, I just won't force y'all to use it.
-David
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development