Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » JS-libraries in custom widgets
JS-libraries in custom widgets [message #1001242] Wed, 16 January 2013 09:56 Go to next message
Christian Hager is currently offline Christian HagerFriend
Messages: 52
Registered: July 2009
Location: Germany
Member
Hello everyone,

I was wondering if someone could tell me what's the best way to integrate JS-libraries and CSS-Resources in custom widgets?

I'm especially interessted in the following to cases:


  1. How would I best integrate a js-library like ckeditor consisting of various js-files, css-files and images?
  2. How would I best integrate a js-library like jquery which which would potentially be used by several of my custom widgets



Thanks in advance for any help or hints.


Christian
Re: JS-libraries in custom widgets [message #1001766 is a reply to message #1001242] Thu, 17 January 2013 10:39 Go to previous message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 387
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/
Previous Topic:Operation "listen" on target "w4" of type "rwt.widgets.MenuBar" failed
Next Topic:RAP Table adds height of horiz scroll bar
Goto Forum:
  


Current Time: Sun Nov 23 02:31:48 GMT 2014

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

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