Re: How to generate the output for a given java collection object

Daniel Henrique Alves Lima <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
    I would try something like

    [#list (itemMap?keys) as key]
       ${key} [#list (itemMap[key]) as item]${item}[/#list]
    [/#list]

   But I'm not sure if FM supports integers as hash keys.

Rajvinder Pal wrote:
> Hi ,
>  
> Following is my java object 'itemMap'.And i want to generate the 
> output as given below
>  
> Map<Integer, Set<String>> itemMap = *new* HashMap<Integer, Set<String>>();
> //id 1
> Integer i1 = *new* Integer(1);
> Set<String> itemSet1 = *new* HashSet<String>();
> itemSet1.add("A");
> itemMap.put(i1, itemSet1);
> //id 2
> Integer i2 = *new* Integer(2);
> Set<String> itemSet2 = *new* HashSet<String>();
> itemSet2.add("B");
> itemSet2.add("C");
> itemMap.put(i2, itemSet2);
> //id 3
> Integer i3 = *new* Integer(3);
> Set<String> itemSet3 = *new* HashSet<String>();
> itemSet3.add("D");
> itemSet3.add("E");
> itemMap.put(i3, itemSet3);
> System./out/.println(itemMap);
>  
> Expected output:
>  
> 1 A
> 2 B C
> 3 D E
>  
> Could anyone let me know how can i generate this using freemarker 
> template?
>  
> Thanks,
> Rajvinder
> ------------------------------------------------------------------------
>

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2

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