Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

acces object variables inside velocity template

jacob delddd
Contributor
August 1, 2018

Is there a way to display object variables inside the velocity template?

It only seems to work with "toString()". I saw something about wrapping the object, but how would this be possible in jira?

example:

java class:

class a
{
public String name;

public String getName(){return "test";}
public String fullUsername = "test";
@Override
public String toString() {return "test";}
}

context.put("object", new a());

 

velocity template:

<html>
<head>
<title>test</title>
<meta name="decorator" content="atl.general">
</head>
<body>
<form id="" class="aui" action="" method="post">

<td>$object.getName()</td> <!-- does not work -->
<td>$object.toString()</td> <!-- works!!! -->
<td> $object.name </td> <!-- does not work -->
</form>
</body>
</html>

 

Thank you for your time!

0 answers

Suggest an answer

Log in or Sign up to answer