How to load web resources in velocity template?

Влад_Демидик July 10, 2018

Hello, i develop plugin for jira.


I have following resources in my xml file. Can someone show example how to use it in velocity template?

 

image.png

Thanks!

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2018

Hello,

You should add to your velocity template something like this:

 $webResourceManager.requireResourcesForContext("pluginkey:jira-plugin-resources")

You can find the plugin key of your plugin in the add-on sections, after you installed your add-on.

Mikhail_Kopylov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2018

@Alexey Matveev looks you've mixed up requireResourcesForContext and requireResource

$webResourceManager.requireResourcesForContext takes context value as a parameter. In this case it will be "jira-plugin"

$webResourceManager.requireResource takes resource key in format "pluginkey:modulekey".

Влад_Демидик July 10, 2018

Thanks. And after how to require it in template?

 

I should call another function? (just a resource name doesn't work)

image.png

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2018

@Mikhail_Kopylov thank you. It must be

$webResourceManager.requireResources("pluginkey:jira-plugin-resources")

You do not need to add the script tag. Your script is already loaded. Try to put alert into your js file and you will see the alert pop-up.

Mikhail_Kopylov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2018

$webResourceManager.requireResource("pluginkey:jira-plugin-resources") actually :)

Влад_Демидик July 10, 2018

Thanks, it works. I became js and css files.

 

But how to load images?

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2018

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events