Re: Calling #Macro Recursively
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Thursday, October 15, 2009, 12:52:31 PM, Daniel Dekany wrote:
> Thursday, October 15, 2009, 6:00:35 AM, rizzz86 wrote:
>
>> Hi,
>>
>> I am trying to call <#macro> recursively.
>> I am getting the StackOVerFlowError, which means that their are unlimited
>> number of calls made wiithin a macro.
>>
>> What I was actually doing is "Rendering a Menu". I have a List that contains
>> a menu bean. That menu bean can also have its children and these children
>> are also a list containing a menu bean.
>>
>> example:
>>
>> class MenuBean {
>>
>> String title;
>> String url;
>> List<MenuBean> children;
>> etc..
>> }
>>
>> I can have N numbers of children for each menu (no limit).
>>
>> My macro is as follows:
>>
>> <#macro menugenerator menuList>
>> <#if menuList??>
>> <#foreach element in menuList>
>> ${element.url} ${element.title} ..... // Generates
>> Menu
>> <#if element.children??>
>> <@menugenerator menuList=element.children/>
>> </#if>
>> </#foreach>
>> </#if>
>> </#macro>
>>
>> Any reasons for the Error :-?
>
> Maybe the children field, when there are no children, is an empty list
> instead of null?
Actually that would cause only one extra call... so it's not that.
> Or... you managed to create a loop in the object
> graph?
>
>
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference