Re: Array error

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
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


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
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.