Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I am trying to implement a JIRA report module. For this I am making use of the AbstractReport class which has generateReportHtml() method.
I have the following data that is being passed from java class to vm file:
Map<String, Object> velocityParams = new HashMap<String, Object>();
...
velocityParams.put("issueKey", issueKey);
velocityParams.put("userName", userName);
velocityParams.put("updateDate", updatedDate);
velocityParams.put("fromIssueType", fromIssueType);
velocityParams.put("toIssueType", toIssueType);
return descriptor.getHtml("view", velocityParams);
I want to display all the data through vm file
But I am unable to display multiple rows using foreach loop
Thanks in advance
Can you give a snippet of the velocity template code you are using to iterate over the map?
At a guess you probably need to do the foreach loop on the map's entrySet. Something like:
#foreach ($mapEntry in $velocityParams.entrySet()) <tr>
<td>$mapEntry.key</td> <td>$mapEntry.value</td>
</tr> #end
If this doesn't help or you don't get a better answer on here, consider posting your question in Atlassian's dedicated developer community: https://developer.atlassian.com/community/
That's the better place for dev related questions like this.
Edit: Fixed URL.
This is the snippet we used for displaying single row in the vm file. But we are unable to display multiple rows using foreach loop.
<tr> <td> $issueKey</td> <td>$userName</td> <td>$updateDate</td> <td>$fromIssueType</td> <td>$toIssueType</td> </tr>
Thanks,
Pooja Singh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the snippit we used for displaying single row in the vm file. But we are unable to display multiple rows using foreach loop
<tr> <td> $issueKey</td> <td>$userName</td> <td>$updateDate</td> <td>$fromIssueType</td> <td>$toIssueType</td> </tr>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the snippit we used for displaying single row in the vm file. But we are unable to display multiple rows using foreach loop
<tr>
<td> $issueKey</td>
<td>$userName</td>
<td>$updateDate</td>
<td>$fromIssueType</td>
<td>$toIssueType</td>
</tr>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you have a collection of issues from somwhere that you are want to loop over?
There are examples in this tutorial showing use of a for each loop in the vm template: https://developer.atlassian.com/jiradev/jira-platform/guides/projects/tutorial-creating-a-jira-report
For example, you can find this snippet in the tutorial:
#foreach ($issue in $issues) <tr> <td width="5%"> </td> #issueLineItem ($issue) <td nowrap> #if($issue.getAssignee()) $issue.getAssignee().getDisplayName() #else $i18n.getText('common.concepts.unassigned') #end</td> <td nowrap>$outlookDate.format($issue.getUpdated())</td> </tr>
#end
But for this to work you need to have got a collection of issues to do the foreach on from somewhere.
I don't see you doing that anywhere in the code you have posted.
Perhaps it will help if you study the code in the tutorial to see where it comes from in that example.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
#foreach ($mapEntry in $velocityParams.entrySet())
<tr>
<td>$mapEntry.key</td>
<td>$mapEntry.value</td>
</tr>
#end
This code is not working for me. something gonna wrong
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still I am getting problem to show data on Velocity template using GetHtml method.
Kindly Please reply me on this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prashant - can you give more information so that someone in the community may help you? We're users just like you, so it is difficult to help without more details.
When you say 'not working', what is not working? Code won't compile? Run-time error? Not displaying what you expect?
What error messages you are seeing?
If no error message, please give some more details about what you are trying to display. What are you expecting to see? What do you actually see?
I would also recommend you try asking for help on the dedicated developer's community. It is much better suited to questions like this: https://developer.atlassian.com/community/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Sam for advise me,
below is the link
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.