How to call a JAVA class from a Web Panel in Jira with velocity?I want to create a right panel that can toggle a button to callback a java class.
templates/random-indicator.vm:
<button class="aui-button aui-button-link">Toggle Button</button>
atlassia-plugin.xml
<web-panel name="randomIndicator" i18n-name-key="random-indicator.name" key="random-indicator" location="atl.jira.view.issue.right.context" weight="1000"> <description key="random-indicator.description">random Indicator</description> <context-provider class="random.jira.random.plugin.randomIndicator"/> <resource name="view" type="velocity" location="templates/random-indicator.vm"/> <label key="random-indicator.title"/></web-panel>
randomindicator.java
package random.jira.random.plugin;import com.atlassian.jira.issue.Issue;import com.atlassian.jira.plugin.webfragment.contextproviders.AbstractJiraContextProvider;import com.atlassian.jira.plugin.webfragment.model.JiraHelper;import com.atlassian.jira.user.ApplicationUser;import java.sql.Timestamp;import java.time.LocalDate;import java.util.HashMap;import java.util.Map;import static java.time.temporal.ChronoUnit.DAYS;public class randomIndicator extends AbstractJiraContextProvider { @Override public Map<String, Object> getContextMap(ApplicationUser applicationUser, JiraHelper jiraHelper) { Map<String, Object> contextMap = new HashMap<>(); Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue"); Timestamp dueDate = currentIssue.getDueDate(); if (dueDate != null) { LocalDate currentTimeInDays = LocalDate.now(); LocalDate dueDateTimeInDays = dueDate.toLocalDateTime().toLocalDate(); long daysAwayFromDueDateCalc = DAYS.between(currentTimeInDays, dueDateTimeInDays); contextMap.put("daysAwayFromDueDate", daysAwayFromDueDateCalc); } return contextMap; }}