|
This chapter describes how you can create custom client-side components as Google Web Toolkit (GWT) widgets and how you integrate them with Vaadin. The client-side implementations of all standard user interface components in Vaadin use the same client-side interfaces and patterns. Google Web Toolkit is intended for developing browser-based user interfaces using the Java language, which is compiled into JavaScript that is executed in the browser. Knowledge of such client-side technologies is usually not needed with Vaadin, as its built-in repertoire of user interface components should be sufficient for most applications. The easiest way to create custom components in Vaadin is to make composite components with the Creation of new widgets involves a number of rather intricate tasks. The Vaadin Plugin for Eclipse makes many of the tasks much easier, so if you are using Eclipse and the plugin, you should find Section 10.2, “Doing It the Simple Way in Eclipse” helpful. If you need more background on the architecture, Section 3.4, “Client-Side Engine” gives an introduction to the architecture of the Vaadin Client-Side Engine. If you are new to Google Web Toolkit, Section 3.2.2, “Google Web Toolkit” gives an introduction to GWT and its role in the architecture of Vaadin. On TerminologyGoogle Web Toolkit uses the term widget for user interface components. In this book, we use the term widget to refer to client-side components made with Google Web Toolkit, while using the term component in a general sense and also in the special sense for server-side components. The Client-Side Engine of Vaadin runs in the web browser as a JavaScript program and renders the user interface components according to state data received from the server. For each server-side component, there is a client-side widget, which renders the content of the particular component type. The client-side engine and all the built-in client-side widgets of Vaadin have been programmed in Java with GWT, and compiled into JavaScript with the GWT Compiler. Developing custom Vaadin components and integrating existing GWT widgets is easy, requiring only Java programming.
You can start with any existing GWT widget or design a new one. To integrate
it with Vaadin, you have to implement the
To use custom widgets, you need to define a widget set
that inherits the For the server-side API, you need a server-side component that can serialize and deserialize its attributes to and from the client-side counterpart.
A server-side component usually inherits the
To summarize, you need to do the following:
Figure 10.1, “Color Picker Package” illustrates the folder hierarchy of the Color Picker example used in this chapter. The example is available in the demo application of Vaadin with URL The
The GWT Compiler takes the root folder of the client-side source code as its argument and compiles all the Java source files into JavaScript. A client-side widget set must therefore be contained within a single package, which in the Color Picker example is the |
Table of Contents
|