Another Idea/Question
"Luther Baker" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hope I'm not bothering anyone's time but wanted to run another idea past
you.
I know that a macro can be implemented by a Java class as well as a text
template.
I have a desire to do 'both' simultaneously.
In otherwords, I would like write
<@editor user/> (where 'user' is some simple POJO that exists on the page
with certain properties).
and have it invoke a Java class (to populate the Map) and then a template
(which uses the Map)
For example:
a) Invoke x.y.z.Editor.execute(Map mapOut, Args args)
{
/*reflect into arg[0] and determine props or just hardcode as here */
mapOut.put("fieldOne", user.firstName); mapOut.put("fieldTwo",
user.lastName);
}
b) Invoke like named macro
<#macro editor>
${fieldOne} ${fieldTwo}
</#macro>
This is obviously a simple example. I think I can do this indirectly by
creating a general Java macro that would perform steps A and B like this:
<@DualMacro editor/>
Where x.y.z.DualMacro.execute(...) could then instantiate the class
(Editor.class) and load the like-named template. I would end up with a bunch
of
<@DualMacro table/>
<@DualMacro signupForm/>
but it would still work. Is there a more elegant way to do this in FM?
-Luther
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user