javajquerygwtgwtquery

Using jquery plugins with Google Web Toolkit?


Is it possible to use jquery plugins within google web toolkit?

There are a lot of excellent plugins available for various UI widgets, such as date/time pickers, searchable dropdowns, etc. In many cases these plugins also come with their own css styles. I'd like to be able to use these plugins and get their values in my gwt application.


Solution

  • From experience you have two options.

    1. You can use GwtQuery which is a gwt native version of much of jquery. For instance "$" is actually a static java class. There are also quite a few plugins and addons that have great support such as the GwtQuery-DND for drag and drop.

    http://code.google.com/p/gwtquery/

    http://code.google.com/p/gwtquery-plugins/

    1. The other option is to role your own for specific examples. If you have a specific jquery plugin that you want and GwtQuery is not for you. You can use gwt jsni interface which essentially allows you to call native javascript using java native interface. There are quite a few plugins that work this way such as Gflot and gcodmirror (which is a native version of the wiki editor I am using now).

    JSNI Documentation
    http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html

    IMHO it is best to stick with GwtQuery as the jquery functions are almost verbatim usable in GwtQuery and you get the added performance boost of having the code compiled and optimized by the gwt compiler.