Re: Setting request scope variables from within macro

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
It should work with both variations. But, maybe there's a
misunderstanding regarding the life-cycle of the global scope here.
When your top-level template terminates, the global scope will be
released. It doesn't correspond to the request.

FreeMarker has no concept of Request-s or anything that's HTTP- or
Servlet-related. So how do you read or write the Request attributes
(if you can at all) is up to the Web Application Framework authors (or
to the application authors).

-- 
Best regards,
 Daniel Dekany


Tuesday, December 4, 2012, 2:59:24 PM, Marc Schipperheyn wrote:

> Hi,
>
> I'm trying and failing to set a request scope variable from within a macro.
>
> I've tried
> <#global delayPhoto = 0>
> <#macro delayedPhoto photo path type="thumb" >
>         <#if (.globals.delayPhoto > 0)>
>                 <#global delayPhoto = .globals.delayPhoto + 1>
>         <#else>
>                 <#global delayPhoto = 1>
> [...]
>
> <#global delayPhoto = 0>
> <#macro delayedPhoto photo path type="thumb" >
>         <#if (delayPhoto > 0)>
>                 <#global delayPhoto = delayPhoto + 1>
>         <#else>
>                 <#global delayPhoto = 1>
> [...]
>
> and some other variations but delayPhoto always 
> remain 0 when the macro is called.
>
> How do I set a request scope variable from within a macro?


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
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.