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> &nbsp; <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.
Community moderators have prevented the ability to post new answers.
I found the error. It was with respect to retrieval of the data in velocity template. Notice the change in the <script> tag.
<div style="height:200px; overflow-y: scroll;"> <table id="tableid" class="aui"> <thead> <script> function load() { var value = $countDetails+"%"; document.getElementById('myprogress').style.width=value; } </script> <style> .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%; } </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> &nbsp; <div class="meter-wrap"> <div id="myprogress" class="meter-value" style="background-color: #0a0;"> </div> </div>
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>
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.