Java Mailing List Archive

http://www.junlu.com/

Home » FreeMarker-user »

Re: [FreeMarker-user] How To define an array

Denis

2011-11-29

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi mousa,

First, I want to say that if you have to write this kind of code in your templates, you may do well to reconsider the layout of your application. Freemarker is for presentation, not for general-purpose programming.

> Hi All,
>
> I wrote the below code :
>
> <#assign content=get_custom_list ("9e3344c0-a641-11e0-9b98-12313d0232b0")>
> ${content}
> <#assign array=[]>
> <#list content as x>
> <#assign array=array+ [x.value]>
> </#list>
> ${array}
>
> *the results is*
> content : [{"value":"4","label":"Jordan 1"},{"value":"13","label":"BEYROUTH
> DT"},{"value":"17","label":"Jordan3"},{"value":"18","label":"Moussa
> Site"},{"value":"20","label":"mousa"}]
>
> *array* : ["4","13","17","18","20"]
>
> My Question is regarding array's result, when I write this code <#assign
> array=[x.value]> instead of the <#assign array=array+ [x.value]>
> *the result will be *
>
> ["20"] so why I need to define this line: *array +*

The assign directive is to assign a new value to a variable. This means the old value is forgotten. When you write array + [x.value], you tell Freemarker to use the old value to build the new value (by adding x).

> , also I need a useful
> link about an array(*how to define an array*)
>
> *Regards,
> Mousa Gharaibeh*
>
>
> --
> View this message in context: http://freemarker.624813.n4.nabble.com/How-To-define-an-array-tp4115028p4115028.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, 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-novd2d
> _______________________________________________
> FreeMarker-user mailing list
> FreeMarker-user@(protected)
> https://lists.sourceforge.net/lists/listinfo/freemarker-user

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, 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-novd2d
_______________________________________________
FreeMarker-user mailing list
FreeMarker-user@(protected)
https://lists.sourceforge.net/lists/listinfo/freemarker-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.