我为基于Atlassian自己的admin configuration form tutorial的现有JIRA插件构建了一个管理配置表单。
到目前为止,单击配置按钮时会出现模板,但有一个问题:我无法访问Velocity ProjectManager类。通过简单地将$projectManager
写入Velocity模板进行显式测试时,字符串本身就会显示在网站上,而不是作为变量解析。如何将其解析为变量?
以下是代码文件的一些缩短版本' admin.vm'和' atlassian-plugin.xml':
admin.vm
<html>
<head>
<title>$i18n.getText("com.example.jira.PluginConfiguration.head")</title>
<meta content="admin_plugins_menu/upm_section" name="admin.active.section">
<meta content="upm-admin-link" name="admin.active.tab">
<meta name="decorator" content="atl.admin">
<meta name="application-base-url" content="$applicationProperties.getBaseUrl()">
$webResourceManager.requireResource("com.example.jira:resources")
</head>
<body id="jira" class="page-type-admin ">
<form name="PluginConfigurationForm" action="/secure/PluginConfiguration.jspa" method="post" style="padding: 0; margin: 0;">
<input type="hidden" name="atl_token" value="${atl_token}" class="aui">
<div>
<h2 class="aui top-label">$i18n.getText('com.example.jira.PluginConfiguration.title')</h2>
</div>
<div class="hidden">
<input name="id" type="hidden" value="${action.id}"> <input
name="returnUrl" type="hidden" value="$!{action.returnUrl}">
</div>
$projectManager
<div class="buttons-container form-footer">
<div class="buttons">
<input accesskey="s" class="button" id="PluginConfiguration-submit"
name="PluginConfiguration" title="Press Ctrl+Alt+s to submit this form"
type="submit" value="$i18n.getText('com.example.jira.PluginConfiguration.input.button.save')">
<a accesskey="`" class="cancel" href="/plugins/servlet/upm"
id="PluginConfiguration-cancel" title="Press Ctrl+Alt+` to cancel">$i18n.getText('com.example.jira.PluginConfiguration.input.button.cancel')</a>
</div>
</div>
</form>
</body>
</html>
Atlassian的-plugin.xml的
<atlassian-plugin key="${project.groupId}.${project.artifactId}"
name="${project.artifactId}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">img/Project_Logo.png</param>
<param name="plugin-logo">img/Project_Logo.png</param>
<param name="configure.url"><![CDATA[/plugins/servlet/ConfigurePlugin/admin]]></param>
</plugin-info>
<resource type="i18n" name="i18n_PluginConfiguration" location="com.example.jira/PluginConfiguration" />
<component-import key="pluginScheduler">
<description>SAL Scheduler</description>
<interface>com.atlassian.sal.api.scheduling.PluginScheduler
</interface>
</component-import>
<component-import key="pluginSettingsFactory"
interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory" />
<component-import key="transactionTemplate"
interface="com.atlassian.sal.api.transaction.TransactionTemplate" />
<component-import key="userManager"
interface="com.atlassian.sal.api.user.UserManager" />
<component-import key="loginUriProvider"
interface="com.atlassian.sal.api.auth.LoginUriProvider" />
<component-import key="renderer"
interface="com.atlassian.templaterenderer.velocity.one.six.VelocityTemplateRenderer" />
<component-import key="applicationProperties"
interface="com.atlassian.sal.api.ApplicationProperties" />
<servlet key="admin-servlet"
class="${project.groupId}.PluginConfigurationServlet">
<url-pattern>/ConfigurePlugin/admin</url-pattern>
</servlet>
<rest key="rest"
path="/project-admin"
version="1.0">
<description>Provides REST resources for the admin UI.</description>
</rest>
<template-context-item key="applicationPropertiesContextItem"
component-ref="applicationProperties" context-key="applicationProperties"
name="Application Properties Context Item" />
<web-section key="ProjectAdminMenu" name="Project Admin Section"
location="admin_plugins_menu" weight="10">
<label>Project</label>
<description key="Project Administration Section"></description>
</web-section>
<web-item key="PluginConfiguration-web-item" name="Plugin Configuration Web Item"
i18n-name-key="com.example.jira.PluginConfiguration-web-item.name"
section="admin_plugins_menu/ProjectAdminMenu" weight="46">
<description i18n-name-key="PluginConfiguration-web-item.description"></description>
<label key="com.example.jira.PluginConfiguration-web-item.label" />
<link linkId="PluginConfiguration-web-item-link">/plugins/servlet/ConfigurePlugin/admin?decorator=admin/</link>
<tooltip>Configure the Project Jira Plugin</tooltip>
</web-item>
<web-resource name="PluginConfiguration Web Resource"
i18n-name-key="com.example.jira.PluginConfiguration-web-resource.name"
key="PluginConfiguration-web-resource">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<description i18n-name-key="PluginConfiguration-web-resource.description"></description>
<context>jira.admin</context>
<transformation extension="js">
<transformer key="jsI18n" />
</transformation>
<resource type="download" name="PluginConfiguration.js"
location="javascript/PluginConfiguration.js">
<property key="content-type" value="text/javascript" />
</resource>
</web-resource>
</atlassian-plugin>