Friday, December 4, 2015, 8:44:12 PM, Ingo Mahnke wrote:

> Hallo!
> I am new to freemarker and I have one question perhaps sombody can help me.
> I have two own directives written in Java and one Template:
>
>
> <@group name="qname" label="Header" render="collapse" id="header">
>    <@select name="kjkjk"/>
> </@group>
>
> When I am inside the execute method of "select" I need access to
> the next parent "group"-Element and I need the 
> value of the "name" attribute. Is this kind of communication between 
> directives possible?

There's no dedicated feature for it (there should be...), but it's
still possible. Both kind of directives (one implemented as an FTL
macro, the other in Java as TemplateDirectiveModel, I assume) can read
and write the so called global variables. Global variables live inside
the Environment object, of which a new one is created for each
Template.process call. In FTL, you create/modify globals as
<#global myVar = someValue>, and just read them as any other variable
(assuming it's not shadowed by another, but then you can still use
.globals.myVar). In Java, you can use Environment.getGlobalVariable
and setGlobalVariable. Of course, you should chose a sufficiently
unique global variable name, like myLib_group_name.

> Thank you!
> Ingo

-- 
Thanks,
 Daniel Dekany


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Reply via email to