Within the Field+Definintions page.
https://developer.atlassian.com/display/GADGETS/Field+Definitions
It reads,
options:[
{
/* These options are hard-coded but could easily be the results of an AJAX call
(E.g. args.projects) or be calculated at run time
Can anyone tell me how its done, been on this problem for two days now.
Okay I figured it out. Here is my code to display a prepopulated list box from a dynamic source (JSON) format, it displays the listbox in the config cycle of a JIRA gadget.
/// In gadget.xml config section config: { descriptor: function (args) { var gadget = this; gadgets.window.setTitle("Choose Baseline..."); // A select box that is populated by the AJAX JSON call in the args: section below var baselineOne = { id: "BL1", userpref: "Testing", type: "select", label: "Baseline One", description: "Select baseline one...", options: args.baselines }; return { fields: [ baselineOne ] }; }, args: function() { // Call AJAX and return JSON format. The REST services class returns return [ { key: "baselines", ajaxOptions: "/rest/baseline-gadget/1.0/baselinecomparison/getBaselines.json" } ]; }() }, // End of config section // The Java method to return the data follows... @GET @AnonymousAllowed @Produces({MediaType.APPLICATION_JSON}) @Path ("/getBaselines") public Response getBaselines(@QueryParam ("projectId") String projectIdString){ Collection<ABaseline> baselines = new ArrayList<ABaseline>(); for(int i = 0; i < 10; i++){ ABaseline abaseline = new ABaseline("https://<CONFIDENTIAL DATA REMOVED>" + (i+1) + "_Baseline", "" + (i+1)); baselines.add(abaseline); } return Response.ok(baselines).cacheControl(null).build(); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.