inputdate.vm file: <form name="form1" method="post" action="/jira/secure/datePlannerUpdateData!upload.jspa"> <td><input type="hidden" name="keyHolder" value="$key"/></td> &nbsp;&nbsp;&nbsp;&nbsp;<b>From Date:</b> <input name="fromDt" id="fromDt"/> <input type=button value="select" onclick="displayDatePicker('fromDt', this);"/> &nbsp;&nbsp;<b>To Date:</b> <input name="toDt" id="toDt"/> <input type=button value="select" onclick="displayDatePicker('toDt', this);"/> &nbsp;&nbsp; <input type="button" value="GO" onclick="CompareDates()"/> </form> atlassian-plugin.xml file: <project-tabpanel key="Monthly Data" name="Monthly Data" class="com.moog.jira.plugins.MonthlyDataCalc"> <label key="Monthly Data">Monthly Data:</label> <description>Calculated monthly data</description> <order>20</order> <resource type="velocity" name="view" location="templates/inputdate.vm" /> </project-tabpanel> <webwork1 key="com.moog.jira.plugins.UpdateDataAction" class="java.lang.Object"> <actions> <action name="com.moog.jira.plugins.UpdateDataAction!upload" alias="datePlannerUpdateData"> <view name="success">/templates/CalculationsView.vm</view> <view name="input">/templates/inputdate.vm</view> </action> </actions> </webwork1> UpdateDataAction.java: package com.moog.jira.plugins; import com.atlassian.jira.web.action.JiraWebActionSupport; import net.sourceforge.jtds.jdbc.Driver; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.app.VelocityEngine; import java.io.StringWriter; import java.io.Writer; import java.sql.*; /** * Created by IntelliJ IDEA. * User: hsumathi * Date: Nov 11, 2011 * Time: 8:58:34 AM * To change this template use File | Settings | File Templates. */ public class UpdateDataAction extends JiraWebActionSupport{ MonthlyDataBean mdb = new MonthlyDataBean(); public String getFromDt() { return fromDt; } public void setFromDt(String fromDt) { this.fromDt = fromDt; } public String getToDt() { return toDt; } public void setToDt(String toDt) { this.toDt = toDt; } private String fromDt; private String toDt; public String getKeyHolder() { return keyHolder; } public void setKeyHolder(String keyHolder) { this.keyHolder = keyHolder; } private String keyHolder; public String doUpload() throws Exception{ String fromdate = getFromDt(); String todate = getToDt(); String ikey = getKeyHolder(); setValueForEffortEstimation(ikey, fromdate, todate); return SUCCESS; } public void setValueForEffortEstimation(String key,String fromDate,String toDate){ Statement st = null; ResultSet rs = null; conn = null; try{ conn = connect(); st = conn.createStatement(); if(fromDate.length() == 0 && toDate.length() == 0){ rs = st.executeQuery("select sum(TIMESPENT) as ActualTime, sum(TIMEORIGINALESTIMATE) as EstimatedTime from jiraissue where pkey like '%" + key + "%' and "+ previousMonth); }else{ rs = st.executeQuery("select sum(TIMESPENT) as ActualTime, sum(TIMEORIGINALESTIMATE) as EstimatedTime from jiraissue where pkey like '%" + key + "%' and "+ givenMonth + fromDate + " and " + toDate); } //rs.next(); Float f = new Float(0.0D); if (rs.next()) { f = new Float(((double)(rs.getLong(1)-rs.getLong(2))/(double)rs.getLong(2))); mdb.setpEffortEstimation(Math.round(f.doubleValue()*100)+"%"); }else{ mdb.setpEffortEstimation(Math.round(f.doubleValue())+"%"); } }catch (Exception e) { e.printStackTrace(); } finally{ try { rs.close(); st.close(); conn.close(); } catch (SQLException ex) { } } } } MonthlyDataBean.java public class MonthlyDataBean { private String pEffortEstimation; public String getpEffortEstimation() { return pEffortEstimation; } public void setpEffortEstimation(String pEffortEstimation) { this.pEffortEstimation = pEffortEstimation; } } Calculationsview.vm: <form> <div> <table cellpadding="5"> <b>Management Review Data</b> <tr><td> Effort Estimation Conformance:</td> <td>$pEffortEstimation</td> </tr> </form> This is the complete flow that I have given to set the value in Calculationsview.vm file from java class but value is not getting set. Do I have to set velocityparameters, is yes how? Can anybody help me out in this. Its very urgent
Community moderators have prevented the ability to post new answers.
Vishwas,
As Nic mentioned, you need to have getter that will get called from velocity.
So assuming pEffortEstimation is method that you need to call from your velocity, then $action.pEffortEstimation will be the call that you need to put into your Velocity template. And in your action class (UpdateDataAction), you need to add a method getpEffortEstimation().
hope this helps,
Raju
Yes I had set, getter method as public
public String getpEffortEstimation() {
return pEffortEstimation;
}
public void setpEffortEstimation(String pEffortEstimation) {
this.pEffortEstimation = pEffortEstimation;
}
still value is not getting showed up. Just if we have getter method will it be enough to publish the value to the velocity file?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Vishwas,
Do $action.pEffortEstimation to get the value. Remember this method is defined in Action class so you need to pass the reference to that object.
And yes you can just create getter method, no need to have setter method if you are not using it.
Hope this helps,
Raju
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And make sure the getter method you add is public or it won't be seen.
~Matt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there anybody who knows answer for this? Do I have to set velocity context for this, if yes how to set it because currently I am not able to see the value for $pEffortEstimation instead it displays $pEffortEstimation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There's nothing in your code to publish any variables into the velocity.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.