Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » JS-libraries in custom widgets
JS-libraries in custom widgets [message #1001242] Wed, 16 January 2013 04:56 Go to next message
Eclipse UserFriend
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 05:39 Go to previous message
Eclipse UserFriend
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:plugin.xml, i18n and umlauts
Next Topic:Operation "listen" on target "w4" of type "rwt.widgets.MenuBar" failed
Goto Forum:
  


Current Time: Wed Jul 23 13:58:00 EDT 2025

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

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

Back to the top