How to load resources in link dialog vm

I have made velocity file which is being used in link dialog. But when I am trying to load the resources using


My resource file defined in web resource are not being loaded.
Here is my atlassian-plugin.xml

 <!--Link screen-->
    <web-item key="" section="create-issue-link-types" weight="110">
        <label key=""/>
        <link linkId="add-test-link">

    <webwork1 key="test.link2" name="Link Test" class="java.lang.Object">
            <action name="" alias="ActionTestLink">
                <view name="success">vm/linkTest.vm</view>
                <view name="error">vm/linkTest.vm</view>

    <web-resource key="link.screen.resources" name="test Link Resources">
        <resource type="download" name="linkTest.js" location="js/linkTest.js"/>
        <resource type="download" name="linkTest.css" location="css/linkTest.css"/>

Location -

For people I explicity invited can you answer or invite people who knows this kind of stuff.

Hi Saurabh. Here are a few things to consider and/or try:

a) Check the <head> of the HTML page that you’re looking at. Does it include elements related to the download of linkTest.js and/or linkTest.css. If it does, try using the URLs in your browser window; are they correct? If those elements are not in the <HEAD>, then we know that the web resources are not being included for some reason.

b) Is it possible that $webResourceManager is not available in the Velocity context for the link dialog? Maybe try printing $webResourceManager.ClassName in the body of the Velocity template. If it’s not in the Velocity context, you could have your webwork action put it there explicitly.

c) The key to your web resource is link.screen.resources. This is a shot in the dark, but I recall having a problem with a web panel that had a similar key, and I solved that problem by replacing the dots with dashes: so link-screen-resources in your case.

Let us know what you find out.


1 Like

So the good news - you’re not doing anything wrong… The problem is that the contents of the dialog in that location is dynamic so webresourcemanager isn’t being called to get the tags.

The fix though is pretty simple.

In your ActionTestLink add:

    public String getScriptTags()
        return this.webResourceManager.getResourceTags("", com.atlassian.plugin.webresource.UrlMode.ABSOLUTE);


Make sure to inject WebResourceManager into the class though - if you’re using SpringScanner it would be:

    private final WebResourceManager webResourceManager;

    public ActionTestLink(final WebResourceManager webResourceManager)
        this.webResourceManager = webResourceManager;

Then in your vm file, just add: $action.getScriptTags(). I should note that you’ll need to add this in the body (if you’re using all of the <html><head>...</head> stuff since everything outside of the <body></body> is removed.

That’s it - the script tag will be put in place when the page loads. You might want to remove the dependency on auiplugin:ajs since it’s already on the page at that point.

This seems to work for me in Chrome and a couple of other browsers.

If you really want to do it cleanly, you could add some javascript to the atl.general context which listens for this particular dialog to load which then loads the extra javascript resources at that point through a rest end point.


Worked perfectly. Thank You