Vaadin

Join Vaadin Log In

Eager to start developing you own applications using Vaadin? This section presents a QuickStart into running and debugging Vaadin demos under Eclipse. The QuickStart includes a web server, so you do not need to have a full-weight web container such as Apache Tomcat installed.

If you have followed the instructions given in Section 2.2, “Setting up the Development Environment”, you can start Eclipse by running C:\dev\eclipse\eclipse.exe (Windows) or /opt/eclipse/eclipse (Linux or OS X). Depending on your environment, you may need to give additional memory settings for Eclipse, as the default values are known to cause problems often in some systems.

When starting Eclipse for the first time, it asks where to save the workspace. You can select any directory, but here we select C:\dev\workspace (Windows) or /home/<user>/workspace (Linux or OS X). We suggest that you also set this as the default.

Close the Eclipse "Welcome" -screen when you are ready to continue.

If you have not yet downloaded the Vaadin package, instructions for downloading and unpacking are available at Section 2.1.1, “Installing the Distribution Package”.

The installation directory of Vaadin contains all necessary files to allow importing it as a ready-to-run Eclipse project:

  1. Start Eclipse with any workspace you like. Switch to the Java Perspective through WindowOpen PerspectiveJava.

  2. Select FileImport... to open the import dialog.

  3. In the Import dialog, select GeneralExisting Projects into Workspace and click Next.

  4. In the Select root directory option, click the Browse button, and select the folder where you unpacked Vaadin, e.g. c:/dev/vaadin-windows-6.x.x. Click OK in the selection window. The Projects list now shows a project named vaadin-examples. Click Finish in the Import window to finish importing the project.

    The newly imported project should look like Figure 2.4, “Vaadin demo project imported into Eclipse”.


    You can now browse the source code of the demo applications in Eclipse. The next section describes how you can run the demos.

Once the project is imported, as described above, you can run the Content Browser, including the demo applications, as follows:

  1. From the main menu, select RunRun Configurations....
  2. From the list on the left, select Java ApplicationVaadin Web Mode.
  3. Click Run.

Note that after the application has been launched once, it appears in the Favorites list. You can then click on the small dropdown arrow on the right side of the Run button on Eclipse toolbar and select Vaadin Web Mode.

Running the application in Web Mode will start an embedded web server and open a browser window with the Content Browser. The default system web browser is opened; make sure that the browser is compatible with Vaadin. The Console view in the lower pane of Eclipse will display text printed to standard output by the application. Clicking on the red Terminate button will stop the server.


Note that executing the web application locally may cause a security warning from your firewall software because of the started web server. You need to allow connections to port 8888 for the Content Browser to work. Also, if the web service fails to start, make sure that no other service is using port 8888.

The Hosted Mode Browser of Google Web Toolkit is a special web browser that runs the client-side GWT Java code as Java runtime instead of JavaScript. This allows you to debug the client-side components in an IDE such as Eclipse.

To run the demo applications in the Hosted Mode Browser of Google Web Toolkit, follow the following steps:

  1. If not already started, start the demo application in Web Mode as described above. We only need the server so close the web browser which is automatically opened.
  2. From the main menu, select RunDebug Configurations... .
  3. From the list select Java ApplicationVaadin Hosted Mode.
  4. Click Debug.

Starting demo applications under the Hosted Mode Browser can take considerable time! This is especially true for the Reservation and Color Picker applications, which require compilation of custom widget sets. During this time, the Hosted Mode Browser is unresponsive and does not update its window. Compiling widget sets can take 5-30 seconds, depending on the hardware.

As with the Web Mode launcher, after you have run the Hosted Mode launcher once, you can click the dropdown marker on right of the Debug button in the toolbar and select Vaadin Hosted Mode.

To use the Hosted Mode Browser in other projects, you need to create a launch configuration in Eclipse. See Section 10.8.6, “Hosted Mode Browser” for more detailed information about the Hosted Mode Browser and how to create the launch configuration.

At some point when developing an application, you want to debug it. Running a web application in debug mode is easy in Eclipse. Next, we will show you how to debug the demo applications by inserting a breakpoint in the Calc example.

  1. Make sure to stop any previous Run command as instructed above at the end of Section 2.3.3, “Running the Demo Applications in Eclipse”.
  2. Select RunDebug Configurations... from the main menu and the Debug configuration window will open.

  3. Select Java ApplicationVaadin Web Mode and click Debug. The server will start and the web browser will open.

  4. Open the source code for the Calc program. It is located in WebContent/WEB-INF/src/com.vaadin.demo.Calc. WebContent/WEB-INF/src is the project's source folder, shown right below the JRE System Library. Double-click the class to open the source code in the editor.

  5. Insert a breakpoint in the init() by right-clicking on the gray bar on the left of the editor window to open the context menu, and select Toggle Breakpoint.

  6. Switch to the browser window and click the Calc link (below More Examples) to open it.

  7. Eclipse encouters the breakpoint and asks to switch to the Debug perspective. Click Yes. The debug window will show the current line where the execution stopped as illustrated in Figure 2.8, “Execution Stopped at Breakpoint in Debug Perspective in Eclipse”:


  8. You can now step forward or use any commands you would normally use when debugging an application in Eclipse. Note that you can only debug the application code in this way. If you are running the Hosted Mode browser you can also insert break-points in client side component code and debug it.

Table of Contents

Preface
1. Introduction
1.1. Overview
1.2. Example Application Walkthrough
1.3. Support for the Eclipse IDE
1.4. Goals and Philosophy
1.5. Background
2. Getting Started with Vaadin
2.1. Installing Vaadin
2.2. Setting up the Development Environment
2.3. QuickStart with Eclipse
2.4. Your First Project with Vaadin
3. Architecture
3.1. Overview
3.2. Technological Background
3.3. Applications as Java Servlet Sessions
3.4. Client-Side Engine
3.5. Events and Listeners
4. Writing a Web Application
4.1. Overview
4.2. Managing the Main Window
4.3. Child Windows
4.4. Handling Events with Listeners
4.5. Referencing Resources
4.6. Shutting Down an Application
4.7. Handling Errors
4.8. Setting Up the Application Environment
5. User Interface Components
5.1. Overview
5.2. Interfaces and Abstractions
5.3. Common Component Features
5.4. Label
5.5. Link
5.6. TextField
5.7. RichTextArea
5.8. Date and Time Input
5.9. Button
5.10. CheckBox
5.11. Selecting Items
5.12. Table
5.13. Tree
5.14. MenuBar
5.15. Embedded
5.16. Upload
5.17. Form
5.18. ProgressIndicator
5.19. Slider
5.20. Component Composition with CustomComponent
6. Managing Layout
6.1. Overview
6.2. Window and Panel Root Layout
6.3. VerticalLayout and HorizontalLayout
6.4. GridLayout
6.5. FormLayout
6.6. Panel
6.7. SplitPanel
6.8. TabSheet
6.9. Accordion
6.10. Layout Formatting
6.11. Custom Layouts
7. Visual User Interface Design with Eclipse (experimental)
7.1. Overview
7.2. Creating a New CustomComponent
7.3. Using The Visual Editor
7.4. Structure of a Visually Editable Component
8. Themes
8.1. Overview
8.2. Introduction to Cascading Style Sheets
8.3. Creating and Using Themes
8.4. Creating a Theme in Eclipse
9. Binding Components to Data
9.1. Overview
9.2. Properties
9.3. Holding properties in Items
9.4. Collecting items in Containers
10. Developing Custom Components
10.1. Overview
10.2. Doing It the Simple Way in Eclipse
10.3. Google Web Toolkit Widgets
10.4. Integrating a GWT Widget
10.5. Defining a Widget Set
10.6. Server-Side Components
10.7. Using a Custom Component
10.8. GWT Widget Development
11. Advanced Web Application Topics
11.1. Special Characteristics of AJAX Applications
11.2. Application-Level Windows
11.3. Embedding Applications in Web Pages
11.4. Debug and Production Mode
11.5. Resources
11.6. Shortcut Keys
11.7. Printing
11.8. Portal Integration
11.9. Google App Engine Integration
11.10. Common Security Issues
11.11. URI Fragment and History Management with UriFragmentUtility
11.12. Capturing HTTP Requests
A. User Interface Definition Language (UIDL)
A.1. API for Painting Components
A.2. JSON Rendering
B. Songs of Vaadin
Index