|
Re: JS-libraries in custom widgets [message #1001766 is a reply to message #1001242] |
Thu, 17 January 2013 10:39 |
Tim Buschtoens Messages: 396 Registered: July 2009 |
Senior Member |
|
|
Hi.
> How would I best integrate a js-library like ckeditor consisting of
> various js-files, css-files and images?
I'll assume we are talking about RAP 2.0.
There are three ways to register the resources: The
ApplicationConfiguration[1] (non-workbench applications only), the
org.eclipse.rap.ui.resources extension point (workbench applications
only) or using the ResourceManager[2] directly.
Using ApplicationConfiguration is simple, but then the resource
registration is part of your application instead of your custom widget.
Using the ResourceManager (e.g. in the custom widgets constructor) is
more flexible. But then you need to check first if the resource is
already registered, so it's not registered multiple times.
You also need deliver the JS to the client (except when using the
extension point), which can be done with the new JavaScriptLoader[3]
service. Here it is not necessary to check if the content was already
loaded, JavaScriptLoader already does that.
> How would I best integrate a js-library like jquery which which would
> potentially be used by several of my custom widgets
I would suggest to have a separate bundle used by the custom widgets. It
will have a util class that uses ResourceManager and JavaScriptLoader to
ensure the library is registered and loaded on the client. The custom
widgets could then call something like: JQuery.ensure();
If you have trouble with the details, just ask me.
Greetings,
Tim
[1] application.addResource( name, loader );
[2] RWT.getResourceManager(), register, isRegistered, and getLocation
[3] RWT.getClient().getService( JavaScriptLoader.class ).require( url );
>
>
> Thanks in advance for any help or hints.
>
>
> Christian
--
Tim Buschtöns
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Powered by
FUDForum. Page generated in 0.03443 seconds