I followed this extremely simple tutorial https://bitbucket.org/bhushan154/jira-issue-tab-panel-tutorial/wiki/Home to add a new issue tab panel. It shows how you can add simple content to the page using stringBuilder. Ideally I would want to use a velocity template as it's much easier to work with and separates the logic appropriately. I have a template file, that contains:
<div class="mod-header"> <h3>$i18n.getText('service-now-tab-panel.label')</h3> </div>
I've tried fiddeling around with this attempting to get it to display data appropriately, it's not doing anything and isn't rendering out content onto the issue detail page. Here's the controllers it's barebones right now as I need to get passed this road block.
package com.verys.jira.plugins.panels; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.atlassian.jira.plugin.issuetabpanel.AbstractIssueTabPanel; import com.atlassian.jira.plugin.issuetabpanel.IssueTabPanel; import com.atlassian.jira.issue.tabpanels.GenericMessageAction; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.crowd.embedded.api.User; import java.util.Collections; import java.util.List; public class ServiceNowTabPanel extends AbstractIssueTabPanel implements IssueTabPanel { private static final Logger log = LoggerFactory.getLogger(ServiceNowTabPanel.class); public List getActions(Issue issue, User remoteUser) { return Collections.singletonList(new GenericMessageAction("" + issue.getReporter().getDisplayName() + "")); } public boolean showPanel(Issue issue, User remoteUser) { return true; } }
The documentation for rendering out velocity templates on issue tab panels is extremely sparse and almost non existent. If someone can just kindly point me in the right direction that would be great.
Also here is the properties file
<issue-tabpanel key="service-now-tab-panel" name="Service Now Tab Panel" i18n-name-key="service-now-tab-panel.name" class="com.verys.jira.plugins.panels.ServiceNowTabPanel"> <description key="service-now-tab-panel.description">The Service Now Tab Panel Plugin</description> <label key="service-now-tab-panel.label">Plugin Test</label> <order>10</order> <resource type="velocity" name="view" location="templates/tabpanels/service-now-tab-panel.vm"/> <supports-ajax-load>true</supports-ajax-load> </issue-tabpanel>
As you can see it has the resource view that points to the correct destination of the .vm file.
Community moderators have prevented the ability to post new answers.
Hi Dyllen!
getActions should return List<IssueAction> and HTML generation is supposed to happen in your IssueAction implementation, getHtml method. You can extend your IssueAction implementation from AbstractIssueAction and it already overrides getHtml() by rendering velocity template named "view".
For more info about Issue Tab panel, please see here : https://answers.atlassian.com/questions/15835336
I as well am struggling through using velocity has it pertains to the issue panel so I appreciate the comments. I am curious if the post you provided your passing parameters to velocity direct and not using the getHtml() method. How then does the getHtml() method relate to the populateVelocityParams? Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Steven M,
AbstractIssueAction provides implementation for getHtml:
public String getHtml() { Map params = new HashMap(); populateVelocityParams(params); return descriptor.getHtml("view", params); } protected abstract void populateVelocityParams(Map params);
And remember sources are your best friend in Atlassian development world .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you! Defiantly directed me down the correct rabbit trail. If I'm following the API correctly it's the IssueTabPanelModuleDescriptor field on AbstractIssueAction which provides the appropriate
String getHtml(String resourceName, Map<String,?> startingParams)
method.
I'm passing in a
HashMap<String, ArrayList<String>> results
which is a database query through to the populateVelocityParams.
public String getHtml() { bambooQueryResults(); populateVelocityParams(results); return descriptor.getHtml("buildInfo", results); } protected void populateVelocityParams(Map results) { }
and in Velocity
#foreach ($build in $results.keySet()) $results.size() $build.key #end
Still working on why this is not rendering anything.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm also taking you up on your suggestion of getting the source code. I have a case open with Atlassian as it indicates for our license we do not have access to those files. I'm unsure what service level we need to have in order to acquire the source code but looking into it. 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.