Re: call java methods

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Friday, March 21, 2008, 8:51:41 PM, Enrique Rodríguez Lasterra wrote:

> Hi all, i want to create some classes that should be configured for
> designers on freemarker templates. This configurations are calls on
> java method that normaly return void.
>
> I know that i can call these methods with
> ${object.method(configPara,)} or <#assign foo =
> object.method(configParam)/> but it's not very clear for template programer.
>
> In JSP world exists <% %> tags to do this kind of things, but i
> think this is not possible on Freemarker, isn't it?

Not out of the box, as FreeMarker is much more a purist. However, you
could write a directive to execute BeanShell that is given as the
nested content. I'm not sure out of my head how could you access the
data-model or the variables that were created in the template, if you
could at all; that part depends on the BeanShell API.

> Why don't we have something like
>
> <#execute>
>     object.method(configParam);
>     object.method2(configParam2);
> </#execute>
>
> Maybe it's a stupid question, but i'm a 4 years user of freemaker
> and i think it could be util in some cases.

Frankly, I think it would be better to re-think the system
architecture in those cases. FTL is a presentation language after all.

-- 
Best regards,
 Daniel Dekany


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
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.