Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Order of resources / external JS libraries
Order of resources / external JS libraries [message #131945] Fri, 08 May 2009 00:47 Go to next message
Eclipse UserFriend
Originally posted by: AM-81.web.de

Hi,
I need to load some external JS libraries in a special order in my RAP
application, because there are some dependencies between them.
Is der a possibility to do this? In an HTML file I declare them
at the head and it works fine all the time.
Now I try to do the same with resources in the
org.eclipse.rap.ui.resources extension, but it doesn't work.
Without any changes it sometimes works and sometimes I get some JS
errors, that a class is not defined or unknown.
Is there a reason why the resources are not always called in the same order?

Thanks for hints

André
Re: Order of resources / external JS libraries [message #132027 is a reply to message #131945] Fri, 08 May 2009 16:08 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Andre,

the internal storage of the extension registry seems not to care
about the order in which extensions were declared.

However I think this should be solved within RAP. An attribute to
specify the order or something like a composite resource extension
in which the application developer can return th resources in a
specific order is needed. Feel free to file an enhancement request.

In the meanwhile you could circumvent the issue if concatenate the
JS files in the right oder and register them as one resource.

HTH
Rüdiger

André Müller wrote:
> Hi,
> I need to load some external JS libraries in a special order in my RAP
> application, because there are some dependencies between them.
> Is der a possibility to do this? In an HTML file I declare them
> at the head and it works fine all the time.
> Now I try to do the same with resources in the
> org.eclipse.rap.ui.resources extension, but it doesn't work.
> Without any changes it sometimes works and sometimes I get some JS
> errors, that a class is not defined or unknown.
> Is there a reason why the resources are not always called in the same
> order?
>
> Thanks for hints
>
> André
Re: Order of resources / external JS libraries [message #132657 is a reply to message #132027] Wed, 13 May 2009 11:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: AM-81.web.de

Hi Rüdiger,

I do what you said. I register now only one resource and dynamically
register my libraries with js in the head.


Thanks for your help. :)


Maybe someone has the same problem, here is my code in the registered
js-file:

var scriptElement1 = document.createElement('script');
scriptElement1.type = 'text/javascript';
scriptElement1.src = '<jsLibrary1>.js';

var scriptElement2 = document.createElement('script');
scriptElement2.type = 'text/javascript';
scriptElement2.src = '<jsLibrary2>.js';
....

var head = document.getElementsByTagName('head')[0];
if( head ){
head.appendChild( scriptElement1 );
head.appendChild( scriptElement2 );
...
}

alert('short break');


the only not so nice thing is, the alert at the end. but it is needed,
otherway it could be that the tags would not correctly registered.





Rüdiger Herrmann schrieb:
> Andre,
>
> the internal storage of the extension registry seems not to care about
> the order in which extensions were declared.
>
> However I think this should be solved within RAP. An attribute to
> specify the order or something like a composite resource extension in
> which the application developer can return th resources in a specific
> order is needed. Feel free to file an enhancement request.
>
> In the meanwhile you could circumvent the issue if concatenate the JS
> files in the right oder and register them as one resource.
>
> HTH
> Rüdiger
>
> André Müller wrote:
>> Hi,
>> I need to load some external JS libraries in a special order in my RAP
>> application, because there are some dependencies between them.
>> Is der a possibility to do this? In an HTML file I declare them
>> at the head and it works fine all the time.
>> Now I try to do the same with resources in the
>> org.eclipse.rap.ui.resources extension, but it doesn't work.
>> Without any changes it sometimes works and sometimes I get some JS
>> errors, that a class is not defined or unknown.
>> Is there a reason why the resources are not always called in the same
>> order?
>>
>> Thanks for hints
>>
>> André
Re: Order of resources / external JS libraries [message #132696 is a reply to message #132657] Wed, 13 May 2009 12:51 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
André,

just for the record, my suggestion was to *concatenate* the files.
I.e. copy the contents of fileA and fileB into a fileAB and register
this file instead.
That would save you the alter for the price of having a lengthy,
maybe harder to edit file.

Cheers,
Rüdiger



André Müller wrote:
> Hi Rüdiger,
>
> I do what you said. I register now only one resource and dynamically
> register my libraries with js in the head.
>
>
> Thanks for your help. :)
>
>
> Maybe someone has the same problem, here is my code in the registered
> js-file:
>
> var scriptElement1 = document.createElement('script');
> scriptElement1.type = 'text/javascript';
> scriptElement1.src = '<jsLibrary1>.js';
>
> var scriptElement2 = document.createElement('script');
> scriptElement2.type = 'text/javascript';
> scriptElement2.src = '<jsLibrary2>.js';
> ....
>
> var head = document.getElementsByTagName('head')[0];
> if( head ){
> head.appendChild( scriptElement1 );
> head.appendChild( scriptElement2 );
> ...
> }
>
> alert('short break');
>
>
> the only not so nice thing is, the alert at the end. but it is needed,
> otherway it could be that the tags would not correctly registered.
>
>
>
>
>
> Rüdiger Herrmann schrieb:
>> Andre,
>>
>> the internal storage of the extension registry seems not to care about
>> the order in which extensions were declared.
>>
>> However I think this should be solved within RAP. An attribute to
>> specify the order or something like a composite resource extension in
>> which the application developer can return th resources in a specific
>> order is needed. Feel free to file an enhancement request.
>>
>> In the meanwhile you could circumvent the issue if concatenate the JS
>> files in the right oder and register them as one resource.
>>
>> HTH
>> Rüdiger
>>
>> André Müller wrote:
>>> Hi,
>>> I need to load some external JS libraries in a special order in my
>>> RAP application, because there are some dependencies between them.
>>> Is der a possibility to do this? In an HTML file I declare them
>>> at the head and it works fine all the time.
>>> Now I try to do the same with resources in the
>>> org.eclipse.rap.ui.resources extension, but it doesn't work.
>>> Without any changes it sometimes works and sometimes I get some JS
>>> errors, that a class is not defined or unknown.
>>> Is there a reason why the resources are not always called in the same
>>> order?
>>>
>>> Thanks for hints
>>>
>>> André
Previous Topic:setTextLimit for Text Doesn't Work?
Next Topic:Strange behavior of FilteredTree
Goto Forum:
  


Current Time: Fri Apr 26 15:05:56 GMT 2024

Powered by FUDForum. Page generated in 0.03216 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top