How do I render a link when writing a macro?

Tobias Rapp July 14, 2013

I want to render a link to some Page object in my macro output. When I use the value of `page.getUrlPath()` and embed it into a string like

<a href="pageUrl">Text</a>

the resulting link does not include the necessary site prefix "/confluence". How do I properly render a link during macro output?

1 answer

1 accepted

0 votes
Answer accepted
Tobias Rapp August 27, 2013

I finally came to a solution that looked like this:

StringBuilder builder = new StringBuilder();
builder.append("<a href=\"")
    .append(bootstrapManager.getWebAppContextPath())
    .append(page.getUrlPath())
    .append("\">")
    .append(page.getTitle())
    .append("</a>");

... hope this helps others with a similar problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events