How to get string list values in velocity template? foreach loop for 3 lists

Hi All,

I have 3 String lists(lets say ListA, ListB and ListC) in my java class which maps to velocity template. I need to display the values of the list in a table.

As velocity allows only foreach loop i can get values of only one list. is there a way to get values from all three lists?

If not in foreach loop, how to access the list values through its index?

 

Any inputs will be much appreciated.

Thanks

1 answer

1 accepted

Hi, 

with a little more investigation i found the answer.

from java class, lets say we have following code with populateVelocityParams method

params.put("listA",ListA);
//Map the below java utils List class 
params.put("list",List.class);

 

then in velocity template, 

just call 

$listA.get(index);
//"index" here is the list integer index position in ListA

 

Thanks,

Sharath TS

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 12, 2018 in Agile

How Davin Studer gets Confluence to do everything he wants it to do...except dishes

  @Davin Studer holds many interests, including but not limited to health tech and Star Trek. Read on to discover more about Davin, from his favorite Confluence macros to his favorite lit...

297 views 3 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you