I'm writing a plugin for a new Web Panel on the issues screen in Jira 5.0.1.
In that panel I pull a field in and try to display it. The field has embedded HTML and I want to format it.
The way to do this appears to be to use $textutils.htmlEncode(xxxx) method in the velocity template, but whatever I do the method does not appear to be called all I get in the output is $textutils.htmlEncode(xxxx) in the output.
If I just output the field contents (i.e. remove the outer htmlEncode method), it appears fine but without formatting.
Am I missing some way of "importing" $textutils into my plugin? I thought it should be in the default velocity context.
Only if you are calling super.getVelocityParameters in your getVelocityParameters method... are you?
You can also populate them with stuff like that by using: JiraVelocityUtils.getDefaultVelocityParams(authenticationContext)
I have no Java in my Plugin at all. All I have is the atlassian-plugin.xml file and the velocity template.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can we see the section of the atlassian-plugin.xml that defines the new panel?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<web-panel name="XXX"
i18n-name-key="xxx.name"
key="xxx"
location="atl.jira.view.issue.right.context"
weight="0">
<description key="xxx.description">XXX</description>
<label>XXX</label>
<resource name="view" type="velocity" location="xxx.vm"/>
</web-panel>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I'm not familiar with doing this without any code. It's possible that you just don't get textutils. Try putting this in your velocity to see what's available:
#foreach($p in $ctx.keySet().toArray()) $p.toString() - $ctx.get($p).getClass().getName().toString() #end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That returns absolutely nothing! Which is odd as I can access $i18n, $customFieldManager and $issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, so in the end I wrote a context provider for my web panel that added an instance of the TextUtils class into the context.
public class ContextProvider extends AbstractJiraContextProvider { public static final TextUtils textUtils = new TextUtils(); public Map getContextMap(User user, JiraHelper jiraHelper) { Map contextMap = new HashMap(); contextMap.putAll(jiraHelper.getContextParams()); contextMap.put("textUtils",textUtils); return contextMap; } }
This then worked brilliantly on the atlas-run development system.
So I copied it across to the 5.0.1. test instance I have only to be presented with the following exception on every issue page:
Error rendering WebPanel (project-info.vm): java.lang.Exception: The specified class for ResourceManager (org.apache.velocity.runtime.resource.ResourceManagerImpl) does not implement org.apache.velocity.runtime.resource.ResourceManager; Velocity is not initialized correctly.
With a very, very long stack trace!
Any ideas?
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.