Re: Calling #Macro Recursively

Daniel Dekany <[email protected]> Thu, 23 Oct 2014 20:05:32 +0200
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

-- 
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------