Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use jquery in GWT application?

Tags:

jquery

gwt

i am newbie for GWT.i had created one simple registration form using GWT.i want to add validation for each field using jquery.please help me to explain that how i am able to use jquery in GWT.

Thanks

like image 213
Sameek Mishra Avatar asked Dec 13 '22 12:12

Sameek Mishra


2 Answers

You'd be better off using gwtQuery, which is a port (not a wrapper) of jQuery to GWT.

Better off because it is Java so you can use it directly without writing tons of wrappers and because GWT will compile only parts (functions) that actually get used, resulting in much smaller code.

like image 61
Peter Knego Avatar answered Jan 01 '23 06:01

Peter Knego


There is no need to use a external lib like jquery. What is jquery good for?

  1. Selecting elements: You dont need to select elements cause you create them all by yourself and you can store them in variables for later use. This more efficient than traversing the DOM later to get the element you're looking for.
  2. Animation: There is a Animation class in gwt that can be easily used to animate CSS properties of elements.
  3. Creating new elements: This can be done with GWT as well.
  4. Events: Can be done with GWT, plus you have an global eventbus and dont need to misuse the window object as eventbus. Also event delegation can be done with GWT, take a look at CellList source code to understand how to deal with it in GWT.

Working with GWT for a half year on a really large project I've seen no need for using external libraries like jquery. The only thing we missed was drag'n drop, we're using gwt-dnd for this.

like image 39
Andreas Köberle Avatar answered Jan 01 '23 06:01

Andreas Köberle