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.
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:
@HtmlSafe
public String getScriptTags()
{
return this.webResourceManager.getResourceTags("com.jira.app.test:link.screen.resources", com.atlassian.plugin.webresource.UrlMode.ABSOLUTE);
}
}
Make sure to inject WebResourceManager into the class though - if you’re using SpringScanner it would be:
@ComponentImport
private final WebResourceManager webResourceManager;
@Inject
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.