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

In Jira 5 external javascript library doesn't included for customfield in "create issue" popup on dashboard

Andrey Polyakov January 7, 2012

I have customfield displayed with some javascript library located in separate file and included as plugin web resource. Everything works well for jira 4.4 and Jira 5 if "Create issue" popup called from createIssue/viewIssue/editIssue screens. But if popup dialog "Create issue" (from top right corner) is called from dashboard then velocity directive:

 $!webResourceManager.requireResource("com.example.plugin:resourceid")

will be fully ignored and as result custom field view would be broken due to missing javascript library.

Is there any way to include external javascript resource for customfield on dashboard screen?

Now I am going to provide more tech details to make problem description more clear.

Plugin descriptor file "atlassian-plugin.xml" contains definition for webresource:

<web-resource key="resourceid" name="External javascript lib">
<dependency>com.atlassian.auiplugin:jquery</dependency>
   <resource type="download" name="jquery-ui-1.8.14.custom.min.js" location="js/jquery-ui-1.8.14.custom.min.js">
    <property key="content-type" value="text/javascript"/>
        </resource>
</web-resource>

And customfield defintion is

    <customfield-type key="exampleCFType" name="Example Custom Field"
                      class="com.example.ExampleCFType">
        <resource type="velocity" name="edit" location="templates/edit-example.vm"/>
 </customfield-type>

where "edit-example.vm" velocity macros contains reference to webresource like:

#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)
...
 $!webResourceManager.requireResource("com.example.plugin:resourceid")
...
#controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)

As result for JIRA screens "Create Issue" and "Edit Issue" result HTML header will contain additional script directive for "resourceid" like :

<html>

<head>

<script type="text/javascript" src=".../js/jquery-ui-1.8.14.custom.min.js"></script>
</head>
...
</html>

and javascript located in javascript work well.

But If I do "Create Issue" from next screen (http://localhost:2990/jira/secure/Dashboard.jspa) then script will

not be included to HTML document header.

Any ideas how to get it work there?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Jeff Kirby
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.
January 9, 2012

I have 2 ideas for you. The first is that you can specify that your web-resource appear in the atl.general context which will make your Javasript appear on the Dashboard. It will also appear a lot of other places, so you'll have to make sure that the Javascript only modifies things when you want them to. You could perhaps check the URL in the Javascript.

Here's a web-resource with context specified

 <web-resource key="css-resource" name="Clean CSS Resource">
      <dependency>jira.webresources:global-static</dependency>
      <description>Reduce font sizes. Remove ugly pipes</description>
      <resource name="palm.css" type="download" location="templates/ui/palm.css"/>
      <context>atl.general</context>
      <context>atl.admin</context>
   </web-resource>

The second idea is to leave off the context and create a servlet filter module that only injects your Javascript for the pages. I have coded something like this a number of times. In fact, it's open-sourced here https://studio.plugins.atlassian.com/svn/HPJIRACOMMONS/trunk/palm-commons-plugin/src/main/java/com/palm/jira/plugin/util/AuthenticatedMonkeyGreaseFilter.java

and an example of using it is here

https://studio.plugins.atlassian.com/svn/HPJIME/trunk/palm-move-plugin/src/main/resources/atlassian-plugin.xml

RambanamP
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.
April 22, 2012

thanks a lot...

TAGS
AUG Leaders

Atlassian Community Events