Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
577 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...