Re: Another Idea/Question

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Sunday, November 16, 2008, 9:09:13 PM, Luther Baker wrote:

> On Nov 13, 2008, at 6:53 AM, Daniel Dekany wrote:
>
>> Saturday, November 8, 2008, 6:29:38 PM, Luther Baker wrote:
>>
>>> Hope I'm not bothering anyone's time but wanted to run another idea  
>>> past you.
>>>
>>> <snip.../>
>>>
>>> but it would still work. Is there a more elegant way to do this in  
>>> FM?
>>
>> I think the usual way of doing this is that you write the "editor"
>> macro in FTL, and then that macro calls out for the java code
>> explicitly:
>>
>> <#macro editor>
>>  <#local m = macroHelpers.editor()> <#-- calls a Java method -->
>>  ${m.fieldOne} ${m.fieldTwo}
>> </#macro>
>>
>>
>
> Regarding 'maroHelper.editor()' ... is that an arbitrary invocation on
> a Java POJO?

Yes.

> or in your example - is 'macroHelpers' the namespace and
> 'editor' a variable name assigned to an instance of some new  
> TemplateMethodModel you might have written in which case, your example
> would execute "exec(List args)" which returns an HashMap type of  
> TemplateModel?

One could do that, but since the object wrapper does it for you
automatically... macroHelper is just a POJO, and editor() is just a
plain method.

> Hope that's not a confusing question. I assume you'd invoke a  
> TemplateDirectiveModel with a different syntax ... so I'm essentially
> just clarifying whether or not you are invoking the exec operation on
> a TemplateMethodModel ... or executing an arbitrary method on a  
> POJO ... or something else that Im missing.
>
> Thanks much,
>
> -Luther

-- 
Best regards,
 Daniel Dekany


-------------------------------------------------------------------------
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=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.