Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Object to access under velocity template.

dhaval soni
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 5, 2013

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.

1 answer

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
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2013

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.

dhaval soni
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 5, 2013

"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 ?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2013

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.

dhaval soni
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 5, 2013

$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.


Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2013

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.

dhaval soni
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 5, 2013

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.

dhaval soni
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 18, 2013

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;

}

instead of keeping direct variable as below:
public Map<Issue, List<Worklog>> allWorkLogs = new Hashtable<Issue, List<Worklog>>();
actually, i tried to access as like C# or .NET getter/setter properties.
Thanks.
dhaval soni
TAGS
AUG Leaders

Atlassian Community Events