Hello,
i created a macro plugin with a list of all spaces and their administrators. To display information about the administrators i used the #usernameLink() function inside the velocity template of my macro.
That worked fine so far but because we did not want any user to have access to that macro, we decided to create a servlet instead. I render the velocity template inside the doGet() method of the servlet:
renderer.render("templates/spaces-list-template.vm", velocityContext, resp.getWriter());
The velocity template looks like this:
<html>
<head>
<title>Bereichsliste</title>
<meta name="decorator" content="atl.admin" />
$webResourceManager.requireResource("de.it.confl.confluence-spaces-list:confluence-spaces-list-resources")
</head>
<body>
<table class="aui">
<thead>
<tr>
<th>Bereich</th>
<th>Koordinierende</th>
</tr>
</thead>
<tbody>
#foreach($spaceData in $spacesData)
<tr>
<td><a href="/confluence/display/$spaceData.key" title="$spaceData.name">$spaceData.name</a></td>
<td>
#foreach($admin in $spaceData.admins)
#if($velocityCount > 1)
,
#end
#usernameLink($admin)
#end
</td>
</tr>
#end
</tbody>
</table>
</body>
</html>
As a result, i get this:
How can i get the #usernameLink() function to render properly?
Thank you.
Hello Alexander,
It's possible that the #usernameLink macro isn't available in your context. I found the source for #usernameLink in \confluence\webapp\template\includes\macros-deprecated.vm:
#*
Link to a user, given their username. If the username doesn't exist, "Anonymous" is printed
deprecated since 5.2
*#
#macro (usernameLink $username)
#trim()
#if ("$!username" != "")
#if ($action.getUserFullName($username))
<a href="#userLinkUrl($!req.contextPath, $username)"
#if($permissionHelper.canView($action.authenticatedUser, $action.getUserByName($username)))
class="url fn confluence-userlink" data-username="$generalUtil.htmlEncode($username)"
#else
class="url fn"
#end
>$generalUtil.htmlEncode($action.getUserFullName($username))</a>
#else
<a href="#userLinkUrl($!req.contextPath, $username)">$username</a>
#end
#else
$action.getText('anonymous.name')
#end
#end
Maybe you could just include that in your .vm file.
Hello Stephen,
that works! Thank you!
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.