I have used jira sdk to create a plugin include web panel.I can used simple Javascript code to get an value of input box in web panel and use "alert()" method to show the value in front page.But I can't find any way to post data to other where.I've tried AJAX and jQuery but nothing changed.Or is there any way to get input value in Velocity from Java class?
Do you want to POST data from the web panel? instead of alert(), put something like this
AJS.$.ajaxSetup({ baseUrl: "http://localhost:8090/jira" // The base url of your instance }); AJS.$.ajax({ url : '/rest/jiragroupmanagementrestresource/latest/group/FOO", type: 'POST', data : {}, // form data cache : false, success: function(response){ alert('Success'); } });
Thank you for your reply.
I tried this code,put them into "
function myFunction() {}
"
Then I use jira quick reload but the web panel throw an error "Error rendering myjava class"
What's wrong?
It is difficult to say without seeing your code. What is myjava.class?
I just copy the code you reply to me in last question.
package com.example.plugins.tutorial;import com.atlassian.crowd.embedded.api.User;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.util.HashMap;import java.util.Map;public class DueDateIndicator extends AbstractJiraContextProvider{private static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000; @Override public Map getContextMap(ApplicationUser applicationUser, JiraHelper jiraHelper) { Map contextMap = new HashMap(); Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue"); Timestamp dueDate = currentIssue.getDueDate(); if (dueDate != null) {int currentTimeInDays = (int) (System.currentTimeMillis() / MILLIS_IN_DAY); int dueDateTimeInDays = (int) (dueDate.getTime() / MILLIS_IN_DAY); int daysAwayFromDueDateCalc = dueDateTimeInDays - currentTimeInDays + 1; contextMap.put("daysAwayFromDueDate", daysAwayFromDueDateCalc); }return contextMap; }}
I think it's nothing wrong with this java class.
It looks like you're new here. Sign in or register to get started.