Calling #Macro Recursively

rizzz86 <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
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>
                       < span class="folder">< a 
href="${element.url}">${element.title}</ a></ span>..... // Generates Menu
                        <#if element.children??>
                            <@menugenerator menuList=element.children/>
                        </#if>
                </#foreach>
        </#if>
</#macro>

Any reasons for the Error :-?
-- 
View this message in context: http://www.nabble.com/Calling--Macro-Recursively-tp25902765p25902765.html
Sent from the freemarker-user mailing list archive at Nabble.com.


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