Setting request scope variables from within macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting request scope variables from within macro

mschipperheyn
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
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: Setting request scope variables from within macro

echineselearning
                Heritage learners Chinese: Give you a Chinese name
       As heritage Chinese learners , you will most likely to want to get a Chinese translation of their English name. This will help the people they are doing business with to pronounce their name as well as remember it. (http://www.echineselearning.com/)
It is also a great show of respect for your business associate’s customs and culture. Another reason to get a Chinese name is if you intend to travel to China or even just for fun. (http://www.echineselearning.com/) 
Most people can write their name, but not everyone can write their name in more than one language. Heritage learners Chinese have a Very solid basic literacy in Chinese! Most of them have the same things with Chinese. (http://www.echineselearning.com/)
Chinese and English differ phonetically, orthographically and grammatically. As a result, the way you write and pronounce your name in Chinese is different to how you would when speaking English. To write your name in Chinese calligraphy you must learn Chinese by writing its characters have a Chinese version of your name and develop your Chinese calligraphy skills.
What do you think about the heritage learners Chinese?  Come and have a try.
You can drill you skills at http://www.echineselearning.com/ to learn Chinese.

What do you think about the Chinese online?  Come and have a try.You can drill you skills at http://www.echineselearning.com/ to learn Chinese.

Reply | Threaded
Open this post in threaded view
|

Re: Setting request scope variables from within macro

Daniel Dekany
In reply to this post by mschipperheyn
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
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user