BTW, I am using template recursion in many of my templates and it worked
just fine. So, might be your specific logic somewhere.
Post by rizzz86Post by rizzz86What more I have found is that the parameter of the macro (i.e. menuList)
might be creating a problem.
I have created two macros "menugenerator1" and "menugenerator2" as
Post by Daniel Dekany<#macro menugenerator1 menuList>
<#if menuList??>
<#foreach element in menuList>
${element.url} ${element.title} ..... // Generates
Menu
<#if element.children??>
menuList=element.children/>
Post by rizzz86Post by Daniel Dekany</#if>
</#foreach>
</#if>
</#macro>
<#macro menugenerator2 menuList>
<#if menuList??>
<#foreach element in menuList>
${element.url} ${element.title} ..... // Generates
Menu
<#if element.children??>
menuList=element.children/>
Post by rizzz86Post by Daniel Dekany</#if>
</#foreach>
</#if>
</#macro>
If I call 2nd macro inside first macro (as shown) ... the 2nd macro will
actually does NOT iterate over the child of element (i.e. element.child
passed as parameter in 1st macro). But it iterates over the same element
(that is in macro 1) and that seems to be the never ending loop.
Then, as I said, maybe you indeed messed up the object graph in the
data-model. Check your *Java* code. It's hardly a FreeMarker problem.
Post by rizzz86Another thing is that when I changed the "parameter names" of both the
macros (i.e. menuList and menuList1 respectvly) ... it calls the right
list
Post by rizzz86in macro 2 (i.e. element.children).
Now what i am thinking is that how can I call the recursive macro with
Look, if you think there is a bug regarding recursion or parameter
names (improbable), construct a self-containing minimal example, and
post that. Now I just can't know what did you mess up where, that may
lead you to false conclusions regarding what matters and what doesn't.
Like, there is nothing special in recursion; when a method calls
itself, the same rules apply as if you call another method. It's not a
special case.
Post by rizzz86rizzz86
Post by Daniel DekanyPost by rizzz86Hi,
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.
class MenuBean {
String title;
String url;
List<MenuBean> children;
etc..
}
I can have N numbers of children for each menu (no limit).
<#macro menugenerator menuList>
<#if menuList??>
<#foreach element in menuList>
${element.url} ${element.title} ..... // Generates
Menu
<#if element.children??>
menuList=element.children/>
Post by rizzz86Post by Daniel DekanyPost by rizzz86</#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
------------------------------------------------------------------------------
Post by rizzz86Post by Daniel DekanyCome 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
Post by rizzz86Post by Daniel Dekanyahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
FreeMarker-user mailing list
https://lists.sourceforge.net/lists/listinfo/freemarker-user
--
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
_______________________________________________
FreeMarker-user mailing list
https://lists.sourceforge.net/lists/listinfo/freemarker-user