Re: Calling #Macro Recursively

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