JIRA在velocity / onchange中获得存储的pluginSettings

时间:2014-10-12 13:44:22

标签: servlets jira velocity jira-plugin

我仍然是JIRA DEV的新手。

总结一下, 我创建了一个插件,可以通过pluginSettings存储一些日期 (https://developer.atlassian.com/display/DOCS/Storing+plugin+settings

所以现在我的问题是,一旦我选择另一个项目,例如SelectOneMenu,我怎样才能实现我的价值观的更新。

首先我将一些参数添加到我的速度上下文中,以便我可以读取pluginSettingsValues。

我的Servlet



@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        
        VelocityTemplatingEngine templatingEngine = ComponentAccessor.getComponent(VelocityTemplatingEngine.class);
        
        PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings();
        
        Map<String, Object> velocityParams = 		ComponentAccessor.getVelocityParamFactory().getDefaultVelocityParams();
        velocityParams.put("projectManager", ComponentAccessor.getProjectManager());
        velocityParams.put("pluginSettings", pluginSettings);
              
        templatingEngine.render(file("ticketSettings.vm"))
        				.applying(velocityParams)
        				.asPlainText(response.getWriter()); 
}
@Override
    protected void doPost(HttpServletRequest req, HttpServletResponse response)
        throws ServletException, IOException {
    PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings();
    
    pluginSettings.put(PROJECT_TICKET + "." +req.getParameter("Projects") + "." + req.getParameter("Prio") + ".editTime", req.getParameter("EditTime"));
    pluginSettings.put(PROJECT_TICKET + "." +req.getParameter("Projects") + "." + req.getParameter("Prio") + ".reactionTime", req.getParameter("ReactionTime"));
 
response.sendRedirect("ticketsettings");
}
&#13;
&#13;
&#13;

在我的Velocity中是一个简单的select元素和目标容器

&#13;
&#13;
<--! Select Menu -->
<select class="select" id="dProj" name="Projects" title="project select">
	 #foreach ($pr in $projectManager.getProjectObjects())
	        <option>$pr.getName()</option>
	  #end    
</select>
 
<--! Conmtent Container -->
<div>
<label>PluginSettings: </label><label>$pluginSettings.get('key')</label>
</div>
&#13;
&#13;
&#13;

当我提交表格时,数据当然会更新。

我想要实现的是,在select元素触发的每个onchange事件上,我希望在我的容器中进行可视化更新,以显示实际数据。

键值应该是来自dProj的选定项目

0 个答案:

没有答案