Not able to access the second key value pair from hashmap in velocity template file

Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2014

I have a hashmap with 2 key value pairs in it. i can access the first value in velocity template file. However when i access the second one it doesnt show any results rather prints the variable again.

Hashmap code extract:

map.put("issueDetails",list);	
System.out.println("percenatgeCalc" + percenatgeCalc);
map.put("countdetails",percenatgeCalc);

when i do System.out for the percentageCalc it prints "60"; this means the second hash map key-value map isnt empty.

Below is the html code for the velocity template file:

<div style="height:200px; overflow-y: scroll;"> 
<table id="tableid" class="aui">
<thead>
	<script>
	function load()
	{
	   document.getElementById('myprogress').style.width=$countdetails.percenatgeCalc;
	}
	</script>
	
	
<style>
.meter-wrap
{
   position: relative;
}

.meter-wrap, .meter-value, .meter-text
{
    /* The width and height of your image */
    width: 500px; height: 10px;
}

.meter-text
{
    position: absolute;
    top:0; left:0;

    padding-top: 5px;

    color: #fff;
    text-align: left;
    width: 100%;
}

 </style>
 
<tr>
<th id="issuetype">Issue Name</th>
<th id="originalest">Org. Est[in Hours]</th>
<th id="remainingest">Remg. Est[in Hours]</th>
</tr>

</thead>


<body onload="load()">		

#foreach( $details in $issueDetails)
    <tr>
        <td id="td1" headers="issuetype">$details.issName</td>
        <td id="td2" headers="originalest">$details.issueEst</td>
        <td id="td3" headers="remainingest">$details.issueRemEst</td>
    </tr>
	
#end


</table>
 
<div class="meter-wrap">
    <div id="myprogress" class="meter-value" style="background-color: #0a0;">
    </div>
</div>

i am able to access the first value of the hashmap i.e.$issueDetails but i cant access $countdetails value.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Jayashree Shetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2014

I found the error. It was with respect to retrieval of the data in velocity template. Notice the change in the <script> tag.

&lt;div style="height:200px; overflow-y: scroll;"&gt; 
&lt;table id="tableid" class="aui"&gt;
&lt;thead&gt;
	&lt;script&gt; function load() { var value = $countDetails+"%"; document.getElementById('myprogress').style.width=value; } &lt;/script&gt;
		
&lt;style&gt;
.meter-wrap
{
   position: relative;
}

.meter-wrap, .meter-value, .meter-text
{
    /* The width and height of your image */
    width: 500px; height: 10px;
}

.meter-wrap, .meter-value
{
    background: #bdbdbd url(/path/to/your-image.png) top left no-repeat;
}

.meter-text
{
    position: absolute;
    top:0; left:0;

    padding-top: 5px;

    color: #fff;
    text-align: left;
    width: 100%;
}

 &lt;/style&gt;
 
&lt;tr&gt;
&lt;th id="issuetype"&gt;Issue Name&lt;/th&gt;
&lt;th id="originalest"&gt;Org. Est[in Hours]&lt;/th&gt;
&lt;th id="remainingest"&gt;Remg. Est[in Hours]&lt;/th&gt;
&lt;/tr&gt;

&lt;/thead&gt;


&lt;body onload="load()"&gt;		
#foreach( $details in $issueDetails)
    &lt;tr&gt;
        &lt;td id="td1" headers="issuetype"&gt;$details.issName&lt;/td&gt;
        &lt;td id="td2" headers="originalest"&gt;$details.issueEst&lt;/td&gt;
        &lt;td id="td3" headers="remainingest"&gt;$details.issueRemEst&lt;/td&gt;
    &lt;/tr&gt;
	
#end


&lt;/table&gt;
&amp;nbsp;

&lt;div class="meter-wrap"&gt;
    &lt;div id="myprogress" class="meter-value" style="background-color: #0a0;"&gt;
    &lt;/div&gt;
&lt;/div&gt;


1 vote
Satyendra Narwane
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2014

Hi Jayashree Shetty,

Can you try this It work fine for me.

Map param =new HashMap();

param.put("issueDetails",list);

param.put("countdetails",percenatgeCalc);

To Render it Velocity Template

<table id="ID" border="1" width="40%" cellspacing="0" cellpadding="1" align="center" >

<tr>

<th id="user" >Users</th>

<th id="resolve">Full Name</a></th>

</tr>

#set ($data=$param.keySet())

#foreach ($issue in $data)

<tr>

<td WIDTH="15%" > $issue </td>

<td WIDTH="15%" > $param.get($issue) </td>

#end

</table>

TAGS
AUG Leaders

Atlassian Community Events