Calling #Macro Recursively

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Calling #Macro Recursively

rizzz86
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 :-?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
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? 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
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
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
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

rizzz86

What more I have found is that the parameter of the macro (i.e. menuList) might be creating a problem.

Example:

I have created two macros "menugenerator1" and "menugenerator2" as follows:

>> <#macro menugenerator1 menuList>
>>         <#if menuList??>
>>                 <#foreach element in menuList>
>>                         ${element.url} ${element.title} ..... // Generates
>> Menu
>>                         <#if element.children??>
>>                             <@menugenerator2 menuList=element.children/>
>>                         </#if>
>>                 </#foreach>
>>         </#if>
>> </#macro>


>> <#macro menugenerator2 menuList>
>>         <#if menuList??>
>>                 <#foreach element in menuList>
>>                         ${element.url} ${element.title} ..... // Generates
>> Menu
>>                         <#if element.children??>
>>                             <@menugenerator2 menuList=element.children/>
>>                         </#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.

Another thing is that when I changed the "parameter names" of both the macros (i.e. menuList and menuList1 respectvly) ... it calls the right list in macro 2 (i.e. element.children).

Now what i am thinking is that how can I call the recursive macro with different parameter names ?? Got something


rizzz86


Daniel Dekany wrote
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
_______________________________________________
FreeMarker-user mailing list
FreeMarker-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
Thursday, October 15, 2009, 1:18:13 PM, rizzz86 wrote:

> What more I have found is that the parameter of the macro (i.e. menuList)
> might be creating a problem.
>
> Example:
>
> I have created two macros "menugenerator1" and "menugenerator2" as follows:
>
>>> <#macro menugenerator1 menuList>
>>>         <#if menuList??>
>>>                 <#foreach element in menuList>
>>>                         ${element.url} ${element.title} ..... //
>>> Generates
>>> Menu
>>>                         <#if element.children??>
>>>                             <@menugenerator2 menuList=element.children/>
>>>                         </#if>
>>>                 </#foreach>
>>>         </#if>
>>> </#macro>
>
>
>>> <#macro menugenerator2 menuList>
>>>         <#if menuList??>
>>>                 <#foreach element in menuList>
>>>                         ${element.url} ${element.title} ..... //
>>> Generates
>>> Menu
>>>                         <#if element.children??>
>>>                             <@menugenerator2 menuList=element.children/>
>>>                         </#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.

> Another thing is that when I changed the "parameter names" of both the
> macros (i.e. menuList and menuList1 respectvly) ... it calls the right list
> in macro 2 (i.e. element.children).
>
> Now what i am thinking is that how can I call the recursive macro with
> different parameter names ?? Got something :confused:

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.

> rizzz86
>
>
>
> Daniel Dekany wrote:
>>
>> 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
>> _______________________________________________
>> FreeMarker-user mailing list
>> [hidden email]
>> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Jeremy Chone
BTW, I am using template recursion in many of my templates and it worked just fine. So, might be your specific logic somewhere. 

On Thu, Oct 15, 2009 at 5:37 AM, Daniel Dekany <[hidden email]> wrote:
Thursday, October 15, 2009, 1:18:13 PM, rizzz86 wrote:

> What more I have found is that the parameter of the macro (i.e. menuList)
> might be creating a problem.
>
> Example:
>
> I have created two macros "menugenerator1" and "menugenerator2" as follows:
>
>>> <#macro menugenerator1 menuList>
>>>         <#if menuList??>
>>>                 <#foreach element in menuList>
>>>                         ${element.url} ${element.title} ..... //
>>> Generates
>>> Menu
>>>                         <#if element.children??>
>>>                             <@menugenerator2 menuList=element.children/>
>>>                         </#if>
>>>                 </#foreach>
>>>         </#if>
>>> </#macro>
>
>
>>> <#macro menugenerator2 menuList>
>>>         <#if menuList??>
>>>                 <#foreach element in menuList>
>>>                         ${element.url} ${element.title} ..... //
>>> Generates
>>> Menu
>>>                         <#if element.children??>
>>>                             <@menugenerator2 menuList=element.children/>
>>>                         </#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.

> Another thing is that when I changed the "parameter names" of both the
> macros (i.e. menuList and menuList1 respectvly) ... it calls the right list
> in macro 2 (i.e. element.children).
>
> Now what i am thinking is that how can I call the recursive macro with
> different parameter names ?? Got something :confused:

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.

> rizzz86
>
>
>
> Daniel Dekany wrote:
>>
>> 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
>> _______________________________________________
>> FreeMarker-user mailing list
>> [hidden email]
>> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user



--
Jeremy Chone
+1 415 699 9912
CTO, VP Product Development and Operations,
www.iJuris.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
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

rizzz86

Thanks for reply.
I am working looking at my Java code now.



JeremyChone wrote
BTW, I am using template recursion in many of my templates and it worked
just fine. So, might be your specific logic somewhere.

On Thu, Oct 15, 2009 at 5:37 AM, Daniel Dekany <ddekany@freemail.hu> wrote:

> Thursday, October 15, 2009, 1:18:13 PM, rizzz86 wrote:
>
> > What more I have found is that the parameter of the macro (i.e. menuList)
> > might be creating a problem.
> >
> > Example:
> >
> > I have created two macros "menugenerator1" and "menugenerator2" as
> follows:
> >
> >>> <#macro menugenerator1 menuList>
> >>>         <#if menuList??>
> >>>                 <#foreach element in menuList>
> >>>                         ${element.url} ${element.title} ..... //
> >>> Generates
> >>> Menu
> >>>                         <#if element.children??>
> >>>                             <@menugenerator2
> menuList=element.children/>
> >>>                         </#if>
> >>>                 </#foreach>
> >>>         </#if>
> >>> </#macro>
> >
> >
> >>> <#macro menugenerator2 menuList>
> >>>         <#if menuList??>
> >>>                 <#foreach element in menuList>
> >>>                         ${element.url} ${element.title} ..... //
> >>> Generates
> >>> Menu
> >>>                         <#if element.children??>
> >>>                             <@menugenerator2
> menuList=element.children/>
> >>>                         </#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.
>
> > Another thing is that when I changed the "parameter names" of both the
> > macros (i.e. menuList and menuList1 respectvly) ... it calls the right
> list
> > in macro 2 (i.e. element.children).
> >
> > Now what i am thinking is that how can I call the recursive macro with
> > different parameter names ?? Got something :confused:
>
> 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.
>
> > rizzz86
> >
> >
> >
> > Daniel Dekany wrote:
> >>
> >> 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
> >> _______________________________________________
> >> FreeMarker-user mailing list
> >> FreeMarker-user@lists.sourceforge.net
> >> 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
> FreeMarker-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>



--
Jeremy Chone
+1 415 699 9912
CTO, VP Product Development and Operations,
www.iJuris.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
_______________________________________________
FreeMarker-user mailing list
FreeMarker-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

firoza
In reply to this post by Jeremy Chone
Hi,
Did we get the solution for the problem?

I am having the same requirement for recursion.
Below is the scenario:

HierarchyView - class

Name
Conf
Material Number
List<HierarchyView> children

I have list of HierarchyView and  n level of HierarchyView children under each object. How could I iterate that in ftl?
Please help.

Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
No FreeMarker-related problem was described in the original thread, as
far as I see. Do you have any specific problem?


Thursday, October 16, 2014, 7:33:52 PM, firoza wrote:

> Hi,
> Did we get the solution for the problem?
>
> I am having the same requirement for recursion.
> Below is the scenario:
>
> HierarchyView - class
>
> Name
> Conf
> Material Number
> List<HierarchyView> children
>
> I have list of HierarchyView and  n level of HierarchyView children under
> each object. How could I iterate that in ftl?
> Please help.
>
> Thanks
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655293.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

firoza
Hi,
I have the requirement to display the recursive objects in ftl.
I am not sure whether using macro is the right option and as per the original thread It didn't mention that we got the solution for such kind of requirement.
Would you please check my last post where I have mentioned my requirement for displaying the recursive list in ftl?

Any help would be highly appreciated.

Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
Write a macro that expects a List<HierarchyView> as argument, and
walks it using #list (just the top level). Inside the #list, after
printing the current item *without* its List<HierarchyView> child, the
macro should call itself by passing that child list in as the
argument. That's the basic idea.

Each macros call has its own local scope, so they won't interfere with
other ongoing macro calls. But don't forget that to set variables in
the local scope, #local must be used, not #assign. (Macro arguments
and the #list loop variables is always local.)


Saturday, October 18, 2014, 9:42:53 AM, firoza wrote:

> Hi,
> I have the requirement to display the recursive objects in ftl.
> I am not sure whether using macro is the right option and as per the
> original thread It didn't mention that we got the solution for such kind of
> requirement.
> Would you please check my last post where I have mentioned my requirement
> for displaying the recursive list in ftl?
>
> Any help would be highly appreciated.
>
> Thanks
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655295.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

firoza
Thanks Deniel for your quick response.
I tired with the approach you suggested but it is not displaying any information on the page.

Below is the code snipped:

HierarchyProductSearchResult{
private Integer chpd;
private Integer conf;
private String link;
private List<String> activeName = Collections.emptyList();
private List<String> inactiveName= Collections.emptyList();
private List<HierarchyProductSearchResult> children = Collections.emptyList();
}

I have a service method which returns list of HierarchyProductSearchResult. That list is productSearchResultList.

In ftl I have created the macro and iterating the loop. Blow is the code in ftl for macro:

<ul class="accordion">
                                                         <#macro hierarchy productSearchResultList>
                                                       
                                                        <#list productSearchResultList as productresult>
                                                       
                                                        <#assign detailViewPopUp="Y">
                                                                <li>                                                                       
                                                                       
                                                                       
                                                                                <#if productresult.children?has_content>
                                                                                        <a href="JavaScript:void(0);" class="accrClick"><@liferay_ui.message key="resultview.hierarchy.click"/>
                                                                               
                                                                                </#if>
                                                                       
                                                                       
                                                                       
                                                                        <#include "include/resultRecordDetails.ftl" >
                                                                       
                                                                        <#if productresult.children?has_content>
                                                                                        <ul>
                                                                       
                                                                                         <@hierarchy productSearchResultList=productresult.children/>
                                                                                        </ul>
                                                                                               
                                                                        </#if>                                                               
                                                               
                                                                </li>
                                                               
                                                        </#list>
                                                        </#macro>



Would you please let me know where I am making the mistake? I got stuck in this.

Thanks

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
FTL only sees public members of public classes. Furthermore with it
default configuration it won't try to read fields, only JavaBean
properties. That is, you need getter methods, as usual in Java.


Sunday, October 19, 2014, 5:16:51 PM, firoza wrote:

> Thanks Deniel for your quick response.
> I tired with the approach you suggested but it is not displaying any
> information on the page.
>
> Below is the code snipped:
>
> HierarchyProductSearchResult{
> private Integer chpd;
> private Integer conf;
> private String link;
> private List<String> activeName = Collections.emptyList();
> private List<String> inactiveName= Collections.emptyList();    
> private List<HierarchyProductSearchResult> children =
> Collections.emptyList();
> }
>
> I have a service method which returns list of HierarchyProductSearchResult.
> That list is productSearchResultList.
>
> In ftl I have created the macro and iterating the loop. Blow is the code in
> ftl for macro:
>
> <ul class="accordion">
>                                                          <#macro
> hierarchy productSearchResultList>
>                                                        
>                                                         <#list
> productSearchResultList as productresult>
>                                                        
>                                                         <#assign detailViewPopUp="Y">
>                                                                
> <li>                                                                
>                                                                    
>                                                                    
>                                                                    
> <#if productresult.children?has_content>
>                                                                    
> <@liferay_ui.message key="resultview.hierarchy.click"/>
> <JavaScript:void(0);>  
>                                                                    
>                                                                     </#if>
>                                                                    
>                                                                    
>                                                                    
>                                                                    
> <#include "include/resultRecordDetails.ftl" >
>                                                                    
>                                                                    
> <#if productresult.children?has_content>
>                                                                     <ul>
>                                                                    
>                                                                    
> <@hierarchy productSearchResultList=productresult.children/>
>                                                                     </ul>
>                                                                    
>                                                                    
> </#if>                                                          
>                                                                
>                                                                 </li>
>                                                                
>                                                         </#list>
>                                                         </#macro>
>
>
>
> Would you please let me know where I am making the mistake? I got stuck in
> this.
>
> Thanks
>
>
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655297.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

firoza
In reply to this post by rizzz86
Yes Daniel, I have getter and setters both in my pojo. And I am using
liferay + freemarker. Setting the list from controller and want to use
it on ftl. This is an Arraylist which holds pojos of the type
HierarchyProductSearchResult. If I just iterate with list tag of ftl
for first level (without macro) I am getting the results displayed on
the screen but for recursive call with maco no contents are displayed.

Thanks

Sent from my Windows Phone From: Daniel Dekany
Sent: ‎19-‎10-‎2014 09:35 PM
To: firoza
Cc: [hidden email]
Subject: Re: [FreeMarker-user] Calling #Macro Recursively
FTL only sees public members of public classes. Furthermore with it
default configuration it won't try to read fields, only JavaBean
properties. That is, you need getter methods, as usual in Java.


Sunday, October 19, 2014, 5:16:51 PM, firoza wrote:

> Thanks Deniel for your quick response.
> I tired with the approach you suggested but it is not displaying any
> information on the page.
>
> Below is the code snipped:
>
> HierarchyProductSearchResult{
> private Integer chpd;
> private Integer conf;
> private String link;
> private List<String> activeName = Collections.emptyList();
> private List<String> inactiveName= Collections.emptyList();
> private List<HierarchyProductSearchResult> children =
> Collections.emptyList();
> }
>
> I have a service method which returns list of HierarchyProductSearchResult.
> That list is productSearchResultList.
>
> In ftl I have created the macro and iterating the loop. Blow is the code in
> ftl for macro:
>
> <ul class="accordion">
>                                                          <#macro
> hierarchy productSearchResultList>
>
>                                                         <#list
> productSearchResultList as productresult>
>
>                                                         <#assign detailViewPopUp="Y">
>
> <li>
>
>
>
> <#if productresult.children?has_content>
>
> <@liferay_ui.message key="resultview.hierarchy.click"/>
> <JavaScript:void(0);>
>
>                                                                     </#if>
>
>
>
>
> <#include "include/resultRecordDetails.ftl" >
>
>
> <#if productresult.children?has_content>
>                                                                     <ul>
>
>
> <@hierarchy productSearchResultList=productresult.children/>
>                                                                     </ul>
>
>
> </#if>
>
>                                                                 </li>
>
>                                                         </#list>
>                                                         </#macro>
>
>
>
> Would you please let me know where I am making the mistake? I got stuck in
> this.
>
> Thanks
>
>
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655297.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Thanks,
 Daniel Dekany

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
Do call that "hierarchy" macro somewhere outside the macro itself?
Because I see #macro after the <ul>, which is a rather unusual
placement for macro definition. #macro just defines a macro, you also
have to call it to generate output.


Monday, October 20, 2014, 5:07:18 AM, Firoza Saiyed wrote:

> Yes Daniel, I have getter and setters both in my pojo. And I am using
> liferay + freemarker. Setting the list from controller and want to use
> it on ftl. This is an Arraylist which holds pojos of the type
> HierarchyProductSearchResult. If I just iterate with list tag of ftl
> for first level (without macro) I am getting the results displayed on
> the screen but for recursive call with maco no contents are displayed.
>
> Thanks
>
> Sent from my Windows Phone From: Daniel Dekany
> Sent: ‎19-‎10-‎2014 09:35 PM
> To: firoza
> Cc: [hidden email]
> Subject: Re: [FreeMarker-user] Calling #Macro Recursively
> FTL only sees public members of public classes. Furthermore with it
> default configuration it won't try to read fields, only JavaBean
> properties. That is, you need getter methods, as usual in Java.
>
>
> Sunday, October 19, 2014, 5:16:51 PM, firoza wrote:
>
>> Thanks Deniel for your quick response.
>> I tired with the approach you suggested but it is not displaying any
>> information on the page.
>>
>> Below is the code snipped:
>>
>> HierarchyProductSearchResult{
>> private Integer chpd;
>> private Integer conf;
>> private String link;
>> private List<String> activeName = Collections.emptyList();
>> private List<String> inactiveName= Collections.emptyList();
>> private List<HierarchyProductSearchResult> children =
>> Collections.emptyList();
>> }
>>
>> I have a service method which returns list of HierarchyProductSearchResult.
>> That list is productSearchResultList.
>>
>> In ftl I have created the macro and iterating the loop. Blow is the code in
>> ftl for macro:
>>
>> <ul class="accordion">
>>                                                          <#macro
>> hierarchy productSearchResultList>
>>
>>                                                         <#list
>> productSearchResultList as productresult>
>>
>>                                                         <#assign detailViewPopUp="Y">
>>
>> <li>
>>
>>
>>
>> <#if productresult.children?has_content>
>>
>> <@liferay_ui.message key="resultview.hierarchy.click"/>
>> <JavaScript:void(0);>
>>
>>                                                                     </#if>
>>
>>
>>
>>
>> <#include "include/resultRecordDetails.ftl" >
>>
>>
>> <#if productresult.children?has_content>
>>                                                                     <ul>
>>
>>
>> <@hierarchy productSearchResultList=productresult.children/>
>>                                                                     </ul>
>>
>>
>> </#if>
>>
>>                                                                 </li>
>>
>>                                                         </#list>
>>                                                         </#macro>
>>
>>
>>
>> Would you please let me know where I am making the mistake? I got stuck in
>> this.
>>
>> Thanks
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655297.html
>> Sent from the freemarker-user mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.
>> http://p.sf.net/sfu/Zoho
>> _______________________________________________
>> FreeMarker-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>>
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

firoza
Hi Deniel,
I tried for recursive call but its not working it's giving errors at runtime.

Below is what i want to achieve:
I have a Java Bean (pojo) with followin fields with getter and setter methods.

The pojos are populated with data using the recursive function of java.

I have productSearchResultList bject which is the list of type HierarchyProductSearchResult(which is populated as metioned above).
Now I want to display this list in ftl

The format is :
//Iterate the productSearchResultList and if the recods has children then open the new ul and display all its children in li.. This will go till n level
<ul>
<li>


        //this entry has children
        <ul>
                <li>
                        <ul>
                        <li></li>
                        </ul>
                </li>       
                <li></li>
                <li></li>
        </ul>
</li>

<li></li>
...
</ul>

In each <li> I need to dispaly the infomation in a table something like this

                       
${productresult.chpd}
${productresult.conf}
${productresult.conf}


The code in FTL:

<div class="col-results">                                       
                                                       
                                                         <#macro hierarchy searchResultList>
                                                        <ul>
                                                        <#list searchResultList as productresult>
                                                       
                                                        <#assign detailViewPopUp="Y">
                                                                <li>                                                                       
                                                                       
                                                                       
                                                                                <#if productresult.hierarchy.children?has_content>
                                                                                        <a href="JavaScript:void(0);" class="accrClick"><@liferay_ui.message key="resultview.hierarchy.click"/>
                                                                               
                                                                                </#if>
                                                                       
                                                                       
                                                                                                                                                                                                                                                                                                                        ........
                                                                       
${productresult.chpd}
${productresult.conf}

                                                                       
                                                                       
                                                                        <#if productresult.hierarchy.children?has_content>
                                                                                       
                                                                       
                                                                                         <@hierarchy searchResultList=productresult.hierarchy.children/>
                                                                                       
                                                                                               
                                                                        </#if>                                                               
                                                               
                                                                </li>
                                                               
                                                        </#list>
                                                        </ul>
                                                        </#macro>

<@hierarchy searchResultList=productSearchResultList/>
               
</div>


Please let me know where I am making the mistake. I got stuck in this.

Thanks,
Firoza
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
I don't believe that solving this problem involves any advanced
FreeMarker features. It's just generic algorithm writing. Thus, if you
have a *minimal* example that demonstrates an aspect of FreeMarker
that you don't get, please post that. Also, when your problem involves
an error, always include the error message.


Thursday, October 23, 2014, 7:43:00 PM, firoza wrote:

> Hi Deniel,
> I tried for recursive call but its not working it's giving errors at
> runtime.
>
> Below is what i want to achieve:
> I have a Java Bean (pojo) with followin fields with getter and setter
> methods.
>
> The pojos are populated with data using the recursive function of java.
>
> I have productSearchResultList bject which is the list of type
> HierarchyProductSearchResult(which is populated as metioned above).
> Now I want to display this list in ftl
>
> The format is :
> //Iterate the productSearchResultList and if the recods has children then
> open the new ul and display all its children in li.. This will go till n
> level
> <ul>
> <li>
>
>
>         //this entry has children
>         <ul>
>                 <li>
>                         <ul>
>                         <li></li>
>                         </ul>
>                 </li>  
>                 <li></li>
>                 <li></li>
>         </ul>
> </li>
>
> <li></li>
> ...
> </ul>
>
> In each <li> I need to dispaly the infomation in a table something like this
>
>
>        
> ${productresult.chpd}
>        
> ${productresult.conf}
>        
> ${productresult.conf}
>
>
>
> The code in FTL:
>
> <div class="col-results">                                      
>                                                        
>                                                          <#macro hierarchy searchResultList>
>                                                         <ul>
>                                                         <#list
> searchResultList as productresult>
>                                                        
>                                                         <#assign detailViewPopUp="Y">
>                                                                
> <li>                                                                
>                                                                    
>                                                                    
>                                                                    
> <#if productresult.hierarchy.children?has_content>
>                                                                    
> <@liferay_ui.message key="resultview.hierarchy.click"/>
> <JavaScript:void(0);>  
>                                                                    
>                                                                     </#if>
>                                                                    
>                                                                    
>                                                                    
>
>                                                                    
> ${productresult.chpd}
>                                                                    
> ${productresult.conf}
>                                                                     ........
>                                                                    
>
>
>                                                                    
>                                                                    
>                                                                    
> <#if productresult.hierarchy.children?has_content>
>                                                                    
>                                                                    
>                                                                    
> <@hierarchy searchResultList=productresult.hierarchy.children/>
>                                                                    
>                                                                    
>                                                                    
> </#if>                                                          
>                                                                
>                                                                 </li>
>                                                                
>                                                         </#list>
>                                                         </ul>
>                                                         </#macro>
>
> <@hierarchy searchResultList=productSearchResultList/>
>                
> </div>
>
>
> Please let me know where I am making the mistake. I got stuck in this.
>
> Thanks,
> Firoza
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655304.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

firoza
In reply to this post by rizzz86
Hi Daniel,
Yes there was some null check needed which i did and i could now see
the results being displayed but now the problem is it just displays the
first level hierarchy. It doesn't continue till n level though we have
data so still the problem is not resolved.




Sent from my Windows Phone From: Daniel Dekany
Sent: ‎23-‎10-‎2014 11:35 PM
To: firoza
Cc: [hidden email]
Subject: Re: [FreeMarker-user] Calling #Macro Recursively
I don't believe that solving this problem involves any advanced
FreeMarker features. It's just generic algorithm writing. Thus, if you
have a *minimal* example that demonstrates an aspect of FreeMarker
that you don't get, please post that. Also, when your problem involves
an error, always include the error message.


Thursday, October 23, 2014, 7:43:00 PM, firoza wrote:

> Hi Deniel,
> I tried for recursive call but its not working it's giving errors at
> runtime.
>
> Below is what i want to achieve:
> I have a Java Bean (pojo) with followin fields with getter and setter
> methods.
>
> The pojos are populated with data using the recursive function of java.
>
> I have productSearchResultList bject which is the list of type
> HierarchyProductSearchResult(which is populated as metioned above).
> Now I want to display this list in ftl
>
> The format is :
> //Iterate the productSearchResultList and if the recods has children then
> open the new ul and display all its children in li.. This will go till n
> level
> <ul>
> <li>
>
>
>         //this entry has children
>         <ul>
>                 <li>
>                         <ul>
>                         <li></li>
>                         </ul>
>                 </li>
>                 <li></li>
>                 <li></li>
>         </ul>
> </li>
>
> <li></li>
> ...
> </ul>
>
> In each <li> I need to dispaly the infomation in a table something like this
>
>
>
> ${productresult.chpd}
>
> ${productresult.conf}
>
> ${productresult.conf}
>
>
>
> The code in FTL:
>
> <div class="col-results">
>
>                                                          <#macro hierarchy searchResultList>
>                                                         <ul>
>                                                         <#list
> searchResultList as productresult>
>
>                                                         <#assign detailViewPopUp="Y">
>
> <li>
>
>
>
> <#if productresult.hierarchy.children?has_content>
>
> <@liferay_ui.message key="resultview.hierarchy.click"/>
> <JavaScript:void(0);>
>
>                                                                     </#if>
>
>
>
>
>
> ${productresult.chpd}
>
> ${productresult.conf}
>                                                                     ........
>
>
>
>
>
>
> <#if productresult.hierarchy.children?has_content>
>
>
>
> <@hierarchy searchResultList=productresult.hierarchy.children/>
>
>
>
> </#if>
>
>                                                                 </li>
>
>                                                         </#list>
>                                                         </ul>
>                                                         </#macro>
>
> <@hierarchy searchResultList=productSearchResultList/>
>
> </div>
>
>
> Please let me know where I am making the mistake. I got stuck in this.
>
> Thanks,
> Firoza
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655304.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Thanks,
 Daniel Dekany

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

Daniel Dekany
So I guess productresult.hierarchy.children?has_content returns false,
does it? In Java, do you have something like
HierarchyProductSearchResult.getHierarchy().getChildren() that's all
public in public classes and returns non-null.


Thursday, October 23, 2014, 9:00:09 PM, Firoza Saiyed wrote:

> Hi Daniel,
> Yes there was some null check needed which i did and i could now see
> the results being displayed but now the problem is it just displays the
> first level hierarchy. It doesn't continue till n level though we have
> data so still the problem is not resolved.
>
>
>
>
> Sent from my Windows Phone From: Daniel Dekany
> Sent: ‎23-‎10-‎2014 11:35 PM
> To: firoza
> Cc: [hidden email]
> Subject: Re: [FreeMarker-user] Calling #Macro Recursively
> I don't believe that solving this problem involves any advanced
> FreeMarker features. It's just generic algorithm writing. Thus, if you
> have a *minimal* example that demonstrates an aspect of FreeMarker
> that you don't get, please post that. Also, when your problem involves
> an error, always include the error message.
>
>
> Thursday, October 23, 2014, 7:43:00 PM, firoza wrote:
>
>> Hi Deniel,
>> I tried for recursive call but its not working it's giving errors at
>> runtime.
>>
>> Below is what i want to achieve:
>> I have a Java Bean (pojo) with followin fields with getter and setter
>> methods.
>>
>> The pojos are populated with data using the recursive function of java.
>>
>> I have productSearchResultList bject which is the list of type
>> HierarchyProductSearchResult(which is populated as metioned above).
>> Now I want to display this list in ftl
>>
>> The format is :
>> //Iterate the productSearchResultList and if the recods has children then
>> open the new ul and display all its children in li.. This will go till n
>> level
>> <ul>
>> <li>
>>
>>
>>         //this entry has children
>>         <ul>
>>                 <li>
>>                         <ul>
>>                         <li></li>
>>                         </ul>
>>                 </li>
>>                 <li></li>
>>                 <li></li>
>>         </ul>
>> </li>
>>
>> <li></li>
>> ...
>> </ul>
>>
>> In each <li> I need to dispaly the infomation in a table something like this
>>
>>
>>
>> ${productresult.chpd}
>>
>> ${productresult.conf}
>>
>> ${productresult.conf}
>>
>>
>>
>> The code in FTL:
>>
>> <div class="col-results">
>>
>>                                                          <#macro hierarchy searchResultList>
>>                                                         <ul>
>>                                                         <#list
>> searchResultList as productresult>
>>
>>                                                         <#assign detailViewPopUp="Y">
>>
>> <li>
>>
>>
>>
>> <#if productresult.hierarchy.children?has_content>
>>
>> <@liferay_ui.message key="resultview.hierarchy.click"/>
>> <JavaScript:void(0);>
>>
>>                                                                     </#if>
>>
>>
>>
>>
>>
>> ${productresult.chpd}
>>
>> ${productresult.conf}
>>                                                                     ........
>>
>>
>>
>>
>>
>>
>> <#if productresult.hierarchy.children?has_content>
>>
>>
>>
>> <@hierarchy searchResultList=productresult.hierarchy.children/>
>>
>>
>>
>> </#if>
>>
>>                                                                 </li>
>>
>>                                                         </#list>
>>                                                         </ul>
>>                                                         </#macro>
>>
>> <@hierarchy searchResultList=productSearchResultList/>
>>
>> </div>
>>
>>
>> Please let me know where I am making the mistake. I got stuck in this.
>>
>> Thanks,
>> Firoza
>>
>>
>>
>> --
>> View this message in context:
>> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655304.html
>> Sent from the freemarker-user mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> FreeMarker-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>>
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling #Macro Recursively

firoza
In reply to this post by rizzz86
Yes Daniel,
First i am checking for productresult.hierarchy?has_content &&
productresult.hierarchy.children?has_content and then calling the macro
<@hierarchy searchResultList=productresult.hierarchy.children />

And i have printed the the complete hierarchy object in controller
before sending to ftl and i could see the hierarchy correctly populated
but that is not getting displayed on ftl.

Firoza

Sent from my Windows Phone From: Daniel Dekany
Sent: ‎24-‎10-‎2014 01:23 AM
To: Firoza Saiyed
Cc: [hidden email]
Subject: Re: [FreeMarker-user] Calling #Macro Recursively
So I guess productresult.hierarchy.children?has_content returns false,
does it? In Java, do you have something like
HierarchyProductSearchResult.getHierarchy().getChildren() that's all
public in public classes and returns non-null.


Thursday, October 23, 2014, 9:00:09 PM, Firoza Saiyed wrote:

> Hi Daniel,
> Yes there was some null check needed which i did and i could now see
> the results being displayed but now the problem is it just displays the
> first level hierarchy. It doesn't continue till n level though we have
> data so still the problem is not resolved.
>
>
>
>
> Sent from my Windows Phone From: Daniel Dekany
> Sent: ‎23-‎10-‎2014 11:35 PM
> To: firoza
> Cc: [hidden email]
> Subject: Re: [FreeMarker-user] Calling #Macro Recursively
> I don't believe that solving this problem involves any advanced
> FreeMarker features. It's just generic algorithm writing. Thus, if you
> have a *minimal* example that demonstrates an aspect of FreeMarker
> that you don't get, please post that. Also, when your problem involves
> an error, always include the error message.
>
>
> Thursday, October 23, 2014, 7:43:00 PM, firoza wrote:
>
>> Hi Deniel,
>> I tried for recursive call but its not working it's giving errors at
>> runtime.
>>
>> Below is what i want to achieve:
>> I have a Java Bean (pojo) with followin fields with getter and setter
>> methods.
>>
>> The pojos are populated with data using the recursive function of java.
>>
>> I have productSearchResultList bject which is the list of type
>> HierarchyProductSearchResult(which is populated as metioned above).
>> Now I want to display this list in ftl
>>
>> The format is :
>> //Iterate the productSearchResultList and if the recods has children then
>> open the new ul and display all its children in li.. This will go till n
>> level
>> <ul>
>> <li>
>>
>>
>>         //this entry has children
>>         <ul>
>>                 <li>
>>                         <ul>
>>                         <li></li>
>>                         </ul>
>>                 </li>
>>                 <li></li>
>>                 <li></li>
>>         </ul>
>> </li>
>>
>> <li></li>
>> ...
>> </ul>
>>
>> In each <li> I need to dispaly the infomation in a table something like this
>>
>>
>>
>> ${productresult.chpd}
>>
>> ${productresult.conf}
>>
>> ${productresult.conf}
>>
>>
>>
>> The code in FTL:
>>
>> <div class="col-results">
>>
>>                                                          <#macro hierarchy searchResultList>
>>                                                         <ul>
>>                                                         <#list
>> searchResultList as productresult>
>>
>>                                                         <#assign detailViewPopUp="Y">
>>
>> <li>
>>
>>
>>
>> <#if productresult.hierarchy.children?has_content>
>>
>> <@liferay_ui.message key="resultview.hierarchy.click"/>
>> <JavaScript:void(0);>
>>
>>                                                                     </#if>
>>
>>
>>
>>
>>
>> ${productresult.chpd}
>>
>> ${productresult.conf}
>>                                                                     ........
>>
>>
>>
>>
>>
>>
>> <#if productresult.hierarchy.children?has_content>
>>
>>
>>
>> <@hierarchy searchResultList=productresult.hierarchy.children/>
>>
>>
>>
>> </#if>
>>
>>                                                                 </li>
>>
>>                                                         </#list>
>>                                                         </ul>
>>                                                         </#macro>
>>
>> <@hierarchy searchResultList=productSearchResultList/>
>>
>> </div>
>>
>>
>> Please let me know where I am making the mistake. I got stuck in this.
>>
>> Thanks,
>> Firoza
>>
>>
>>
>> --
>> View this message in context:
>> http://freemarker.624813.n4.nabble.com/Calling-Macro-Recursively-tp626735p4655304.html
>> Sent from the freemarker-user mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> FreeMarker-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>>
>

--
Thanks,
 Daniel Dekany

------------------------------------------------------------------------------
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
12
Loading...