I have an issue "ISSUE1" and it has 3 subtasks "SUBTASK1","SUBTASK2","SUBTASK3".
I am able to display the following data in the issue view page in the format given below:
Issue Type Estimate
ISSUE1 3h
SUBTASK3 2h
The first 2 subtasks dont get added since it gets oevrwriiten by the html code in the .vm file
--------------------------------------
<style> thead {color:blue;} #table1,#issuetype,#originalest,#td1 { border:1px solid black; } </style> <table id="table1" class="aui"> <thead> <tr> <th id="issuetype">Issue Type</th> <th id="originalest">Original Estimate</th> </tr> </thead> <tbody> <tr> <td id="td1" headers="issuetype">$issuename</td> <td id="td1" headers="originalest">$issestimate</td> </tr> <tr> <td id="td1" headers="issuetype">$sbiname</td> <td id="td1" headers="originalest">$sbiestimate</td> </tr> </tbody> </table>
------------END-------------------------
How can i avoid this? I have kept a counter $count in the vm file to know the count of subtasks created through which i can increase the row size and add it. But somehow i am not able to understand how to write the logic. Can anyone help me to write the code for the velocity file?
Community moderators have prevented the ability to post new answers.
your modified class should be as follows
public Map getContextMap1(User user, JiraHelper jiraHelper){ Map map = new HashMap(); List<IssueDetailsBean> list=new ArrayList<IssueDetailsBean>(); Issue currentIssue =(Issue)jiraHelper.getContextParams().get("issue"); String iss_name=currentIssue.getIssueTypeObject().getName(); Long iss_est = currentIssue.getOriginalEstimate(); IssueDetailsBean issDetailBean; if(iss_name.equalsIgnoreCase("PBI")){ //map.put("issuename", iss_name); //map.put("issestimate",iss_est/hours + "h"); if(currentIssue.getSubTaskObjects()!=null){ Collection<Issue> subtasks = currentIssue.getSubTaskObjects(); int size = subtasks.size(); Iterator<Issue> enumerator1 = subtasks.iterator(); while(enumerator1.hasNext()){ Issue item = enumerator1.next(); //String issueID=item.getIssueTypeId(); //map.put("sbiname", item.getSummary()); //map.put("sbiestimate" ,item.getOriginalEstimate()/hours + "h"); issDetailBean=new IssueDetailsBean(iss_name,iss_est,item.getSummary(),item.getOriginalEstimate());//pass all varible values here list.add(issDetailBean); } } } map.put("issueDetails",list); return map; }
write bean class as follows
public class IssueDetailsBean { String issNname; Long issueEst; String sbiName; Long sbiestimate; public IssueDetailsBean(String issNname, Long issueEst, String sbiName, Long sbiestimate) { super(); this.issNname = issNname; this.issueEst = issueEst; this.sbiName = sbiName; this.sbiestimate = sbiestimate; } public String getIssNname() { return issNname; } public void setIssNname(String issNname) { this.issNname = issNname; } public Long getIssueEst() { return issueEst; } public void setIssueEst(Long issueEst) { this.issueEst = issueEst; } public String getSbiName() { return sbiName; } public void setSbiName(String sbiName) { this.sbiName = sbiName; } public Long getSbiestimate() { return sbiestimate; } public void setSbiestimate(Long sbiestimate) { this.sbiestimate = sbiestimate; } }
in vm file you can access data as follows
#foreach( $details in $issueDetails ) $details.issName ... #end
i am not a java developer i have started using java for development in JIRA. I am unaware of java beans. I had a doubt. You have commented out assigning pbi and sbi values to the map at the initial state. So is it that this Bean will have to hold pbi variable and sbi variable?We add all pbi(issue) and subtasks values to the map at the end?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i updated my answer so you can use as it is!
Answer for your Q, yes the values will be stored in bean class object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Prasad. I understood the bean class. i am not clear about accessing the vm file. Does this wont get overwritten? How can i access the PBI and all its subtasks without having the any subtask getting overwritten.
I can loop through each element and get the value but how will my table get to know how many data is present and to increment the row of teh table and display the data
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the table row count will depends on number of objects present in list, you no need to bother about row count!!
access data as follows in vm
<tbody> #foreach( $details in $issueDetails ) <tr> <td id="td1" headers="issuetype"> $details.issName </td> <td id="td1" headers="originalest"> $details.issueEst </td> </tr> <tr> <td id="td1" headers="issuetype"> $details.sbiName </td> <td id="td1" headers="originalest"> $details.sbiestimate </td> </tr> #end </tbody>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot Prasad. I modified the above code a little bit since PBI used to get repeated each time we fetch a SBI.
<table id="table1" class="aui"> <thead> <tr> <th id="issuetype">Issue Type</th> <th id="originalest">Original Estimate (in Hours)</th> </tr> </thead> <tbody> <tr> <td id="td1" headers="issuetype">$details.issName</td> <td id="td1" headers="originalest">$details.issueEst</td> </tr> #foreach($details in $issueDetails) <tr> <td id="td1" headers="issuetype">$details.sbiName</td> <td id="td1" headers="originalest">$details.sbiestimate</td> </tr> #end <tbody> </table>
But now the PBI name and estimate isnt getting displayed. It displays this way
$details.issName$details.issueEst
Also on addition of each sbi the list goes on increasing. do we have scrollbar for a web-pael?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is because of you are accessing those varibles outside of loop, if those varible shoud't be repeated then need to put some condition!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can we add scrollbar to web-panel? Since if i have some 20 subtasks the screen seems to be increasing in height. Instead of having scroll bar to the entire issue screen page can we add the scroll bar to the web panel itself?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can do it, just google it like 'vertical scroll bar for html table'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if my answers helped then don't forgot to mark it as answers :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did that :) it worked :)
Added <div style="height:200px; overflow-y: scroll;"> before the start of the table tag
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Updated Code: public Map getContextMap(User user, JiraHelper jiraHelper) { Map map = new HashMap(); List<IssueDetailsBean> list=new ArrayList<IssueDetailsBean>(); Issue currentIssue =(Issue)jiraHelper.getContextParams().get("issue"); String iss_name=currentIssue.getIssueTypeObject().getName(); Long iss_est = currentIssue.getOriginalEstimate(); if(iss_name.equalsIgnoreCase("PBI")) { if(currentIssue.getSubTaskObjects()!=null) { IssueDetailsBean issDetailBean= new IssueDetailsBean(iss_name,iss_est/hours); list.add(issDetailBean); Collection<Issue> subtasks = currentIssue.getSubTaskObjects(); Iterator<Issue> enumerator1 = subtasks.iterator(); while(enumerator1.hasNext()) { Issue item = enumerator1.next(); IssueDetailsBean issueSbi =new IssueDetailsBean(item.getSummary(),item.getOriginalEstimate()/hours); list.add(issueSbi); } } } map.put("issueDetails",list); return map; } Velocity File: <table id="tableid" class="aui"> <thead> <tr> <th id="issuetype">Issue Type</th> <th id="originalest">Original Estimate</th> </tr> </thead> <tbody> #foreach( $details in $issueDetails ) <tr> <td id="td1" headers="issuetype"> $details.issName</td> <td id="td1" headers="originalest">$details.issueEst</td> </tr> #end </tbody> </table>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have you gone through the following document?
https://developer.atlassian.com/display/JIRADEV/Web+Panel+Plugin+Module
in web panel module you need add "context-provider" element and implement all your logic in that class and then you can access those data on vm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasad yes i have . I do have the data in the context provider. As explained above i have a hashmap created.
@Override
public Map getContextMap(User user, JiraHelper jiraHelper)
{
Map map = new HashMap();
Issue currentIssue =(Issue)jiraHelper.getContextParams().get("issue");
String iss_name=currentIssue.getIssueTypeObject().getName();
Long iss_est = currentIssue.getOriginalEstimate();
if(iss_name.equalsIgnoreCase("PBI"))
{
map.put("issuename", iss_name);
map.put("issestimate",iss_est/hours + "h");
if(currentIssue.getSubTaskObjects()!=null)
{
Collection<Issue> subtasks = currentIssue.getSubTaskObjects();
int size = subtasks.size();
Iterator<Issue> enumerator1 = subtasks.iterator();
while(enumerator1.hasNext())
{
Issue item = enumerator1.next();
String issueID=item.getIssueTypeId();
map.put("sbiname", item.getSummary());
map.put("sbiestimate" ,item.getOriginalEstimate()/hours + "h");
}
}
}
return map;
}
This is returning the issue PBI with hours and its subtasks. But wha is happening is that data from the subtask gets overwritten everytime with the new value. So i need to retain this and display all the subtask values. So i dont know how can i change the veloclity file.
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.