Hi all,
I am currently trying to create a Jira Plugin and am struggling with context provision for a velocity template that is being used in a webwork module.
I created a Web-Panel first, where it was possible to reference a ContextProvider class and everything worked fine.
Now, I want to build pretty much the same page, but instead of using a Web-Panel I want to use a Webwork module. The problem for me here is, that my velocity template is somehow missing context and in comparison to the Web-Panel I am not providing one (no context-provider). How can I make the context known to the velocity template?
I am kind of new in software development and thus the solution may be very simple, but for me unfortunately it is not. I would be very greatful, if anyone could explain to me (in a simple and understandable way) how I can solve my problem. Thanks in advane!
Here are the important code snippets.
Webwork:
<webwork1 key="project-panel-module" name="Project Panel Module" i18n-name-key="project-panel-module.name">
<description key="project-panel-module.description">The Project Panel Module Plugin</description>
<actions>
<action name="com.atlassian.jira.testtron.webwork.ProjectPanelAction" alias="ProjectPanelAction">
<view name="project-panel">/templates/project/project-panel.vm</view>
</action>
</actions>
</webwork1>
ProjectPanelAction class:
@SupportedMethods({RequestMethod.GET})
public class ProjectPanelAction extends JiraWebActionSupport
{
private static final Logger log = LoggerFactory.getLogger(ProjectPanelAction.class);
@Override
public String execute() throws Exception {
return "project-panel";
}
}
Context Provider class that worked for the Web-Panel:
@Named
public class JobPanelContextProvider implements ContextProvider {
private final JobServiceAdapter jobServiceAdapter;
@Inject
public JobPanelContextProvider(JobServiceAdapter jobServiceAdapter) {
this.jobServiceAdapter = jobServiceAdapter;
}
@Override
public Map<String, Object> getContextMap(Map<String, Object> context) {
final ResultDisplay jobDisplays = jobServiceAdapter.readFeatureJobListForHead();
context.put("resultDisplay", jobDisplays);
return context;
}
}
Part of the Velocity Template. Basically none of the variables can be resolved:
<table id="delayedSortedTable" class="aui aui-table-sortable">
<thead>
<tr>
<th>Issue</th>
<th>Erfolgreich</th>
<th>Fehlgeschlagen</th>
<th>Total</th>
<th class="aui-table-column-unsortable"></th>
</tr>
</thead>
<tbody>
#foreach( $job in $resultDisplay.jobs )
<tr>
<td><a href="$job.issueLink">$job.issueDisplayName</a></td>
<td>
<aui-badge>$job.successful</aui-badge>
</td>
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.