Re: Array error
"Zoran Avtarovski" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Thanks Daniel, That's perfect. Appreciate your help. Z. On Mon, 13 Sep 2010 23:28:19 +0200 Daniel Dekany <[email protected]> wrote: >FreeMarker can't modify arrays (or List-s or Map-s). However your > example FTL could be rewritten as: > > <#assign colItems=[ > parameters.colItem1?1, > parameters.colItem2?1, > parameters.colItem3?1]> > > Note that it can concatenate two sequences (array or List) though, > however if you do a lot (tens or rather hundreds) of such > concatenations, the resulting sequence will have a big access time. > > > Monday, September 13, 2010, 2:35:00 PM, Zoran Avtarovski wrote: > >> Hi, >> >> I’m having some issues modifying one of my struts freemarker >> templates. Freemarker is throwing an error when I try to access the >>array. >> >> This is the code that is throwing the error: >> >> <#assign optionCounter = 1 /> >> <#assign colNumber = 0 /> >> <#assign colItems = [1,1,1]> >> <#if parameters.colItem1??> >> <#assign colItems[0] = parameters.colItem1 /> >> </#if> >> <#if parameters.colItem2??> >> <#assign colItems[1] = parameters.colItem2 /> >> </#if> >> <#if parameters.colItem3??> >> <#assign colItems[2] = parameters.colItem3 /> >> </#if> >> >> Put simply I set an integer array colItems with default values of >> 1. Then I test for tag parameters, if they are present I overwrite >>the default value. >> >> The error is generated when I use the square bracket notation ‘[‘ >> to set the value of the array items. >> >> Any help would be appreciated. >> >> Z. > > -- > Best regards, > Daniel Dekany > ------------------------------------------------------------------------------ _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user