Add custom javascript file to teamwork tab

24 views
Skip to first unread message

Ilya Ushakov

unread,
Apr 19, 2017, 10:23:07 AM4/19/17
to TopBraid Suite Users
Hi Everyone,
I need to add a new tab in taxonomy after "Export" tab with button that will call my servlet.
To do that i made next:
1. I added new tab creating subclass of teamwork:ProjectPlugin

2. made javascriptfile myfile.js with content:
$(document).ready(function() {
    $('#sendReleaseS3').click(function(event) {
    var projectGraph = encodeURIComponent($("input[name='projectGraph']").val())

            $.get('ReleaseServlet', {
            projectGraph : projectGraph
            }, function(responseText) {
                    $('#ajaxReleaseServletResponse').text(responseText);
            });
    });
});

3. created subclass of class from item 1. and put int ui:headIncludes
<ui:group>
    <script src="lib/myproject/js/myfile.js" type="text/javascript"/>
</ui:group>

After deploy my project in evn 5.3 i didn't see my javascript file.

What I did wrong?


P.S. If i add new link on any existing tabs (for example general, manage, export etc.) that opens new page and try to include my file there, everything will work fine. 




Holger Knublauch

unread,
Apr 19, 2017, 6:53:41 PM4/19/17
to topbrai...@googlegroups.com
Hi Ilya,

the process sounds correct to me. Could you clarify:

a) are you not seeing the <script> tag in your HTML
b) is the <script> tag produced but the .js file is not found?

In the case of a) is the file with the ui:headIncludes a .ui.ttlx file?

Thanks
Holger
--
You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include the TopBraid Suite family of products and its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbrai...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ilya Ushakov

unread,
Apr 20, 2017, 4:06:25 AM4/20/17
to TopBraid Suite Users
Hi Holger, Thank toy for your reply.

Rather case a), because on view page source in browser i don't see any mentions on may script.


In the case of a) is the file with the ui:headIncludes a .ui.ttlx file?

This file is not .ui.ttlx file, usual .ttl file but imported to ui.ttlx file. 
Did you want to say that for my script to be available on new tab i have to include my script to ui:headIncludes of ui.ttlx file. If yes, in which ui.ttlx file i must add my script?

Holger Knublauch

unread,
Apr 20, 2017, 4:11:46 AM4/20/17
to topbrai...@googlegroups.com


On 20/04/2017 18:06, Ilya Ushakov wrote:
Hi Holger, Thank toy for your reply.

Rather case a), because on view page source in browser i don't see any mentions on may script.

In the case of a) is the file with the ui:headIncludes a .ui.ttlx file?

This file is not .ui.ttlx file, usual .ttl file but imported to ui.ttlx file. 
Did you want to say that for my script to be available on new tab i have to include my script to ui:headIncludes of ui.ttlx file. If yes, in which ui.ttlx file i must add my script?

No, it should be sufficient as long as the .ttlx file is owl:imported into a .ui.ttlx file. However, it is possible that the server did not refresh completely if no .ui.ttlx file was among the uploaded files. So using .ui.ttlx for all SWP files is a better choice. If you have a chance to restart the server, and the issue disappears, this would verify this theory. If none of this helps, we'd need more details.

Holger

Ilya Ushakov

unread,
Apr 21, 2017, 9:16:25 AM4/21/17
to TopBraid Suite Users
Hi Holger, thank you for your reply. 
Yes, I restarted server, cleared browser using cntrl+shift+del combinations for different browsers and the problem didn't disappear. 
May be we need to apply ui:override to some of teamwork components in our ui.ttlx file or in .ttl file that imported to ui.ttls file?

Holger Knublauch

unread,
Apr 21, 2017, 7:04:43 PM4/21/17
to topbrai...@googlegroups.com
Hi Ilya,

where did you attach the ui:override to? It should be to (a superclass of) a component that is used on the page where the JS is used. Something like teamwork:Elements should always work.

Holger

Ilya Ushakov

unread,
Apr 26, 2017, 4:42:33 AM4/26/17
to TopBraid Suite Users
Hi Holger,
Inside of my *.ui.ttlx file I made a clone of swa:Elements, add there my custom js file and put swa:Elments into ui:overrides property there. 
It  works. But, from my point of view, it is quite dangerous solution because, in this case, my clone will executing everywhere in EVN even, as far as i understand, in other custom applications. 

Holger Knublauch

unread,
Apr 26, 2017, 7:37:35 AM4/26/17
to topbrai...@googlegroups.com
Yes, in that case find the most specific component that is only used by your application. And no need to clone the component first - just attach the override to the existing URI resource. This works even if the resource is from another file.

Sent from my iPad
Reply all
Reply to author
Forward
0 new messages