Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Pass Array[][] of Strings to velocity and loop it

BetaConnect
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 22, 2017

Hey guys,

 

I tried as follows:

String[][] retHours =  readResponseMessage(soapResponse);
contextMap.put("currentAXTimes", retHours);
return contextMap;

 

String[][] returnArray = null;

returnArray = new String [nodes.getLength()][2];
for (int i = 0; i < nodes.getLength(); i++)
{
     returnArray[i][0] = nodes.item(i).getAttributes().getNamedItem("Label").getNodeValue();
     returnArray[i][1] = nodes.item(i).getTextContent();
}

Example: retHours

["Billable"]["77,5]

["Invest"]["17,5]

In velocity Iam trying to print the values:

#foreach($axTimes in $currentAXTimes )
    <li>$axTimes[0] / $axTimes[1]</li>
#end

Jira shows me the following String:

[Ljava.lang.String;@65d25310[0] / [Ljava.lang.String;@65d25310[1]
[Ljava.lang.String;@4b31f659[0] / [Ljava.lang.String;@4b31f659[1]

At least it gets the size of the array correctly (2), but somehow it wont show any values

 

Maybe you guys could give me some hints. Unfortunatelyjava is new for me.

 

Thanks in advance - Alex

 

1 answer

0 votes
Fabio Racobaldo _Herzum_
Community Champion
March 18, 2025

Hi @BetaConnect ,

it seems that you are passing a matrix but you are trying to access objects as an array. In order to read an element you should read elements as follow :

$axTimes[0][0] / $axTimes[0][1]

Hope this helps,

Fabio

Suggest an answer

Log in or Sign up to answer