Re: Dynamic Keys in a loop
Attila Szegedi <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Instead of: CONTENT_BEAN.AUTHOR_AUTHOR_NAME[i] you have to use: CONTENT_BEAN["AUTHOR_AUTHOR_NAME" + i] or possibly even: CONTENT_BEAN["AUTHOR_AUTHOR_NAME" + i?c] Attila. -- twitter: http://twitter.com/szegedi weblog: http://constc.blogspot.com home: http://www.szegedi.org On 2010.02.22., at 22:21, CJ wrote: > Hi, > > All the data are String objects (Java) > > The data model being passed to me has key-values as follows: The count indicates > how many name-email pairs are in the data model > > CONTENT_DATA.AUTHOR_COUNT=2 > CONTENT_DATA.AUTHOR_NAME1=John Doe > [email protected] > CONTENT_DATA.AUTHOR_NAME2=Jane Doe > [email protected] > > In the FTL I want to loop through and output the name and email, something along > these lines > > <#assign x=CONTENT_BEAN.AUTHOR_COUNT?number> > <#list 1..x as i> > <#if CONTENT_BEAN.AUTHOR_AUTHOR_NAME[i]?exists>Author Name: > ${CONTENT_BEAN.AUTHOR_NAME[i]}</#if> > <#if CONTENT_BEAN.AUTHOR_EMAIL[i]"?exists>Author Email: > ${CONTENT_BEAN.AUTHOR_EMAIL[i]}</#if> > </#list> > > I've tried quite a few things but nothing seem to work, any help is greatly > appreciated. > > Regards, > CJ ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev