Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to include a webresource from velocity template

Séb P.
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.
August 26, 2013

Hi all,

I'm trying to include a javascript resource from a velocity template, but none of my try are working...

I have the following webresource:

<!-- add our web resources -->
	<web-resource key="fatca-jira-plugin-resources" name="fatca-jira-plugin Web Resources">
		<dependency>com.atlassian.auiplugin:ajs</dependency>

		<resource type="download" name="fatca-jira-plugin.css"
			location="/css/fatca-jira-plugin.css" />
		<resource type="download" name="fatca-jira-plugin.js"
			location="/js/fatca-jira-plugin.js" />
		<resource type="download" name="images/" location="/images" />

		<context>fatca-jira-plugin</context>
	</web-resource>

And on the velocity file, I tried several options:

${webResourceManager.requireResourcesForContext("fatca-jira-plugin")}

or

#requireResource("com.xxx.fatca-jira-plugin:fatca-jira-plugin-resources")

with or without "#includeResources()"

<html> <head>

&lt;!-- missing inclusion here!! --&gt;
&lt;script type="text/javascript"&gt;
 function load() {
   Fatca.openBO();
 }
 &lt;/script&gt;
&lt;/head&gt;
&lt;body onload="load()"&gt;
&lt;/body&gt;
&lt;/html&gt;
Any idea? I'm really stuck on this...

Thanks in advance!!

					
				
			
			
			
				
			
			
			
			
			
			
		

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Séb P.
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.
August 27, 2013

Hi,

Yeah I've tried this too... Indeed, it uses webwork1 to render, but in the final markup this instruction get discarded and not replaced with anything...

Thank you for the tip about Soy/Clojure, but my plugin will not be used for a long time (this is a one-shot, everything will go to trash in a year), so I'd like to use things I already know...

Anyway, I have workarounded it using the atl.general context in my web-resource definition. This way it works, even if it is included in a lot of pages where it shouldn't. But that is not a big issue for me :)

1 vote
Pawel Niewiadomski
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.
August 27, 2013

Should be $webResourceManager.requireResourcesForContext("fatca-jira-plugin"), it also depends what part renders the code. My answer assumes that this is rendered using webwork action.

BTW if you're starting with a new plugin I'd advise to use Soy/Clojure templates and JIRA is currently moving towards them.

What you will get is a lot of already available templates that you can re-use from JIRA and AUI. Here's a list of Soy templates available from AUI - https://bitbucket.org/atlassian/aui/src/814a20176ed3/auiplugin/src/main/resources/soy/atlassian?at=master

Saurabh Gupta May 24, 2017

Facing the same problem can not use generic contexts. I would love if someone told me proper fix for this problem.

Saurabh Gupta May 24, 2017

I don't know how, but this line started working for me

-

<context>com.temp-plugin</context>

#requireResourcesForContext("com.temp-plugin")

 

TAGS
AUG Leaders

Atlassian Community Events