I want to access object prooperty under velocity template.
but it shows as below while trying to use passed velocityparameter under velocity template.
have passed
ReportObject rptObject = ReportObject();
velocityparameters.put("reportObject", rptObject);
In template, when i try to access rptObject's properoty through $reportObject.allWorkLogs
then, it shows as below:
<span>com.tutorial.jira.plugin.Reports.ReportObject@fa8de9.allWorkLogs // instead of showing properoty value.
Please correct me for the syntax here.
Community moderators have prevented the ability to post new answers.
What is a ReportObject and what type of object does allWorkLogs return?
I suspect your velocity is simply getting an object back that it cannot display without further processing. Like a hashmap you need to iterate through or some internal Jira object type.
"ReportObject" is a class which i have created and trying to refer it's properties into velocity template.
allWorkLogs is a type of Map<Issue,List<Worklog>>
also other properties are - startdate, enddate which are type of "date".
Does it possible to access this object's prooperties into velocity template ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If allWorkLogs is a map, then you need to iterate through it to extract data from it in your velocity.
I'd also try exposing reportObject.startdate to see how velocity handles a date object when it tries to display it - I'd actually expect you to see something recognisable as a date at least.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
$reportObject.startDate prints "$reportObject.startDate" as it is .
$reportObject.$startDate prints "com.tutorial.jira.plugin.Reports.ReportObject@fa8de9.$dpDate"
please share your comments.. I will fine for any other alternatives to use custom object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, that implies there's nothing in startDate in the reportObject you have retrieved. Is startDate an attribute or a function? If it's a function, you need reportObject.startDate( ) to fetch the result.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
all are properities as below:
public Map<Issue, List<Worklog>> allWorkLogs = new Hashtable<Issue, List<Worklog>>();
public DateTimeFormatter startDate;
I have also tried to add one new property as below
public String s ;
and it shows me same as it is ..
$reportObject.s // while render. (instead of showing assigned string (i.e. - "temp string var").
if i pass direct parameter to the velocityParameters and then only, i can see the string or date.
but while passing through the object then it shows me as shown behavour.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry to update bit late.
the issue was resolve.
I needed to create methods instead of keep public variables into object and then all methods accessible through velocity object.
public Map<Issue, List<Worklog>> GetAllWorkLogs()
{
return _allworklogs;
}
public void SettAllWorkLogs(Map<Issue,List<Worklog>> value)()
{
_allworklogs = value;
}
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.