Hi, I'm developing a plugin that gets form values and displays them on a new page. The form values contain html tags. However, when I use ${variable-name}, the tags are not rendered. What do I do to render the html elements?
My action class:
package com.example.plugin;
import com.atlassian.confluence.core.ConfluenceActionSupport;
import com.opensymphony.xwork.Action;
public class ComparatorPluginResultAction extends ConfluenceActionSupport {
private String pageVersion1;
private String pageVersion2;
public String execute() throws Exception { return Action.SUCCESS; }
public String getPageVersion1() { return this.pageVersion1; }
public String getPageVersion2(){ return this.pageVersion2; }
public void setPageVersion1(String pageVersion1){ this.pageVersion1 = pageVersion1; }
public void setPageVersion2(String pageVersion2){ this.pageVersion2 = pageVersion2; }
}
My velocity template:
<!DOCTYPE HTML>
<html>
<head>
<title>Compare Results</title>
<meta name="decorator" content="atl.general" />
#requireResource(com.example.plugin.comparator-plugin:comparator-plugin-resources)
</head>
<body>
<div id="compare-div">
<div id="col1">${pageVersion1}</div>
<div id="col2">${pageVersion2}</div>
</div>
</body>
</html>
This seems to be correct in general, but you need to put some values to "pageVersion1" and "pageVersion2" variables in your "execute" method
And for HTML tags you need to use @HtmlSafe annotation
com.atlassian.velocity.htmlsafe.HtmlSafe;
https://developer.atlassian.com/server/confluence/advanced-html-encoding/
Alex
Hey Alex, thanks for the reply. I found a solution before seeing your answer.
I added these 2 lines in the velocity template:
#set($pageVersion1WithHtml = $pageVersion1) <!-- to render html elements -->
#set($pageVersion2WithHtml = $pageVersion2)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.