Using GWT Widgets

Hey,

I was wondering if it’s possible to use out of the box GWT widgets with Vaadin? The motivation isn’t so much to actually use the widgets, as to be able to use external libraries that do use them (in my case, gwt-voices). For instance, if I try something like:

com.google.gwt.user.client.ui.Widget w = new Button();

I get a NoClassDefFoundError at runtime for com/google/gwt/user/client/ui/Button. I’ve tried placing gwt-user.jar into the WEB-INF/lib folder, and tried creating a new widgetset and recompiling, and neither seemed to solve the problem.

Thanks for any help!

Gabor

Gabor,

you cannot just drop an existing gwt widget, you’ll need make a couple of adjustments into it, provide a server side for the widget and register widget in your custom widgetset. However, typically, those adjustments are quite small and fast to implement (unless you’re trying to reuse some heavy widget with a lot of business methods and options/settings in it)

Please take a look at Book of Vaading and samples - they show how to create your own widgetset. There is also several projects in incubator which also adopt external gwt widgets and are good places to look.

Dmitri

Thanks for the response! I’ll take a look at some of the projects in the incubator, and try to adapt the widgets in the library.

Thanks,

Gabor

Here is a pointer to book that explains how to create new Vaadin widgets:
http://vaadin.com/book/-/page/gwt.html

If you are using eclipse, use the plugin:
http://vaadin.com/eclipse/
.

With the plugin, adding new widgets is as simple as

  1. New → Vaadin Widgetset → Ok
  2. New → Vaadin Widget → Ok
  3. Change the created widget stub to extend the existing GWT widget you are integrating
  4. Implement updateFromUIDL() in the client side class
  5. Implement paintContent() in the server side class
  6. Implement changeVariables() in the server side class

And in the end. Remember to tell about your experience here on forums :slight_smile: