<context>alt.general</context> required to load javascript Edited

 <web-resource key="myPlugin-resources" name="myPlugin Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="myPlugin.css" location="/css/myPlugin.css"/>
<resource type="download" name="highcharts.js" location="/js/highcharts.js"/>
<resource type="download" name="myPlugin.js" location="/js/myPlugin.js"/>
<resource type="download" name="images/" location="/images"/>
<context>myPlugin</context>

In order for highcharts to work, the following is required:

<context>atl.general</context>

This causes our main jira instance to crash due to the scripts running on every page of Jira and having undefined vars (the scripts need to run with the context of the plugin only!).

 

Also, what is the plugin name that should go between the context tag? Is it the name that is defined in pom.xml file under 'artifactId' tag or 'name' tag or something else? (I have tried both, and no luck)

 

How to fix this?

 

Please advise.

1 answer

1 accepted

1 vote
Micky Caritte Community Champion Nov 29, 2017

Hi Sevak,

Plugins can have multiple contexts for different pages or servlets based on your needs. When you set a context, it must be required in the precises places you want to use it for resources to be injected. When you use atl.general context, the script is therefore injected in all pages which is the expected behaviour.

If you build a JiraWebAction associated with a velocity template, you have to add the context required by your action using the following in your vm file:

$webResourceManager.requireResourcesForContext("groupAmbassadors")
$webResourceManager.requireResourcesForContext("groupAmbassadorsUsersUsage")

The whole web resources mechanism is well documented here: https://developer.atlassian.com/confdev/confluence-plugin-guide/confluence-plugin-module-types/web-resource-module

The above mentioned page explains how to load your resources in different objects.

Hope this helps!

Cheers

Thanks, Micky.

Working now.

Micky Caritte Community Champion Nov 29, 2017

Great!

Please check this question as answered if you don't mind, that might help people in the same situation to find their way through this.

Welcome in the complex but fascinating family of Jira Apps developers, I am myself still improving but learnt a lot and loved it!

Have a great day!

Will do.

Yes, def. Thx! 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

213 views 1 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you