Re: Components

Attila Szegedi <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
On 2008.11.03., at 7:19, Luther Baker wrote:

> Finally, TemplateDirectiveModel.execute has a Map object ... not JDK  
> 1.5 ... so in my other framework code I've been casting or using a  
> HashMap<String,Object> to push things into template. That has worked  
> so for --- as in the execute method, I have successfully retrieved  
> things like SimpleScalar from the params argument. So, is this the  
> correct way to retrieve a string argument from the macro invocation  
> when the macro is implemented in Java?
>
>          SimpleScalar page = (SimpleScalar) params.get("page");

A string in FreeMarker won't necessarily be a SimpleScalar, but it'll  
always be a TemplateScalarModel, so cast to it instead:

(TemplateScalarModel)page = (TemplateScalarModel) params.get("page");

Attila.


-------------------------------------------------------------------------
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.