Re: Access the Environment "localContextStack" ....

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Wednesday, May 19, 2010, 7:22:26 PM, Tom Fennelly wrote:

>
> Daniel Dekany wrote:
>>> Hi guys.
>>>
>>>  From inside the execute method of a TemplateDirectiveModel 
>>> implementation, is it possible to gain access to the local context stack
>>> on the passed Environment instance (freemarker 2.3.11)? 
>>>
>>> I have a template like this...
>>>
>>>     <#list bean.aaas as aaa>   
>>>     <@writeBean aaa />
>>>     </#list>
>>>
>>> Inside the <@writeBeans> Directive impl, I can see (with a debugger) 
>>> that it has the data I want (the aaa loop instance).  Problem is... the
>>> access method is protected :(
>>>     
>>
>> You mean the "aaa" loop variable? That should be in a "param"
>> parameter of TemplateDirectiveModel.execute(..., Map params, ...).
>> However, TemplateDirectiveModel parameters must be named, and yours is
>> positional. Didn't it give an error?
>>   
> Ah OK... thanks Daniel.... I did <@writeBean bean="aaa" /> and looked up
> the bean inside the TemplateDirectiveModel impl.... all works good 
> now.... thanks!!!
>
> I didn't get an error.

<sigh/> Indeed, it silently ignores it. Yet another quirk that can't
be fixes on a 100% BC way. /-:

> What's the right way of resolving an object graph type reference e.g. 
> <@writeBean bean="order.customer" /> ?

<@writeBean bean=order.customer />

In FreeMarker tags do not quote anything but string literals.

> T.
>

-- 
Best regards,
 Daniel Dekany


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