3logy
3logy

Reputation: 2712

How to add GWTQuery to an existing Vaadin Project?

I am new to Vaadin and GWT but i'm an advanced javascript Programmer. Now im working on a Vaadin existing Project and want to use the great possibilities of jQuery into my Project... how can i add GWTQuery into an existing Vaadin Project?

Upvotes: 0

Views: 670

Answers (2)

Eliran Malka
Eliran Malka

Reputation: 16263

Same as you would for any other GWT project:

  1. Place the GWTQuery JAR under a folder on your project's path (it is not necessary to locate it under WEB-INF/lib, as it is not required during runtime).
  2. Include it in the build path for your project (e.g. in eclipse - right click the JAR file and select Build Path > Add To Build Path).
  3. Add a corresponding entry in the module xml:

    <inherits name="com.google.gwt.query.Query" />
    

Be sure to run the GWT compiler before running in production mode.

Further Reading:
Organizing Projects on the Google Developers' GWT docs.

Upvotes: 1

1.- If you are using maven add these lines to your pom.xml:

<dependency>
 <groupId>com.googlecode.gwtquery</groupId>
 <artifactId>gwtquery</artifactId>
 <version>1.2.0</version>
 <scope>provided</scope>
</dependency>

Otherwise download gwtquery-1.2.0.jar from the project site and include it in your classpath

2.- Add this line to your_application.gwt.xml file:

<inherits name='com.google.gwt.query.Query'/>

3.- Import statically methods from the GQuery class

import static com.google.gwt.query.client.GQuery.*;

4.- Use it to enhance your dom or widgets

$("css_selector").css("width", "100%");
$("css_selector", my_widget).hide();

5.- Be aware that you cannot use jquery plugins, but you can use the core api of jquery (with some differences). There are many gquery plugins though.

Upvotes: 1

Related Questions