Atlassian JIRA Plugin Development: How to make variables available to velocity templates

Deadly 提交于 2019-12-19 14:37:23

问题


FAIR WARNING: this question is going to be pretty tough to answer unless you have experience with JIRA and have access to their source (enterprise users).

Greetings all,

I am writing a plugin which extends AbstractIssueSelectAction. I noticed that ${issue.summary}, etc are all available from within my velocity template, however, there are other things I wish to expose. I can't figure out how to add other things to the velocity parameter map. I even used a remote debugger to try to step through the stack and figure out what is going on - but it was pretty unclear to me both due to a deep stack and the fact that I wasn't able to correctly attach all of the source (and lots of the webwork stuff seems to be obfuscated).

I have posted this question on the Atlassian support forums also, I am just cross-posting here to get more eyes on the problem.

Example action code:

public class MyOperation extends AbstractIssueSelectAction {

    // ...
    private final Issue myIssue;

    public String doCollect() throws Exception {
      log.debug("Running doCollect()");
      return "collectinfo";
    }
 }

Example plugin config:

  <webwork1 key="unique_key" name="My Name" class="java.lang.Object">
   <actions>
    <action name="com.mycompany.jira.extensions.MyOperation" alias="MyOperation">
     <view name="collectinfo">/templates/myoperation-collectinfo.vm</view>
     <view name="success">/templates/myoperation-success.vm</view>
    </action>
   </actions>
  </webwork1>

In the velocity template, ${issue.summary} correctly resolves to the current issue's summary, but if myIssue was some other issue, for example, I want to be able to use ${myIssue.summary}.

Thanks! -Carl


回答1:


How about using $action.mymethod() to get at the information, where mymethod is a method you define in the Action class "MyOperation"? The velocity parameters are fiddly to find out how they get populated.

~Matt



来源:https://stackoverflow.com/questions/1507241/atlassian-jira-plugin-development-how-to-make-variables-available-to-velocity-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!