Book Image

Vaadin 7 Cookbook

Book Image

Vaadin 7 Cookbook

Overview of this book

Table of Contents (19 chapters)
Vaadin 7 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

It is really expensive and demanding to develop Rich Internet Applications from scratch. Vaadin is an amazing framework that contains many ready-made components for the creation of user interfaces. Applications created in Vaadin are compatible with all the latest versions of web browsers. Although the screenshots in this book are from Chrome, examples can also run on other browsers such as Firefox Mozilla, Internet Explorer, and Opera.

The Vaadin 7 Cookbook contains many practical recipes that we have gathered during the development of Vaadin applications. This book will help you to take your learning experience to the next level by providing you with many solutions to the commonly-faced problems along with explanations. There is even more than that. This book goes beyond the basics and shows you how to build Vaadin applications for real-world scenarios.

The Vaadin 7 Cookbook starts with the creation of a project in various tools and languages then moves to components, layouting, events, data binding, and custom widgets. Vaadin, together with Grails, is a powerful tool for the rapid development of RIA applications. This is described in the chapter on how to work with GORM. The quality and stability of the application, testing the Vaadin code, and the data management of Vaadin is also explained in detail.

This book is focused on learning and understanding how to work with Vaadin as well as trying out Vaadin with other technologies such as Grails.

What this book covers

Chapter 1, Creating a Project in Vaadin, shows how to create projects that support three languages—Java, Groovy, and Scala.

Chapter 2, Layouts, is about the practical concepts of layouts in the Vaadin framework. It describes controlling components using the CSS layout, aligning components on the page, creating bookmark-able applications, dragging and dropping between different layouts, and building any layout with AbsoluteLayout.

Chapter 3, UI Components, describes how to use server-side components such as ListSelect, Slider, the very useful Table component, and more. We will learn how to visualize data using the Flot chart and Highcharts libraries. We will also describe how to drag-and-drop components.

Chapter 4, Custom Widgets, describes how to create client-side widgets. We will show you how to extend text field widgets from the GWT library. We will learn how to use listeners on the GWT widgets, how to share state between widgets and components, and how to call native JavaScript.

Chapter 5, Events, describes using the events and listeners on the Vaadin components. We will learn how to react on the mouse click and the double click. It also describes using actions that can be grouped in the context menu. We will also learn how to use two different ways to handle server-push events.

Chapter 6, Messages, helps you with the implementation of validation errors, tool tips, component inside a pop-up view, confirmation window, or how to work with progress bars.

Chapter 7, Working with Forms, describes the creation of various forms with different fields. We will learn how to generate fields from a Java bean, how to validate the user's input, and how to filter items using the ComboBox component.

Chapter 8, Spring and Grails Integration, helps you with the integration of Spring into a Vaadin application. It also shows how to build Vaadin applications inside the Grails project.

Chapter 9, Data Management, helps us to understand the concept of the Vaadin Data Model that consists of three levels: Property, Item, and Container. It also describes filtering data in the table—using a new function called Converters—and storing data in the cookies.

Chapter 10, Architecture and Performance, describes ways and benefits coming from building Vaadin application with the Model View Presenter design pattern. We will see how to improve the performance of Vaadin applications and how to make Vaadin applications visible for search engines.

Chapter 11, Facilitating Development, shows you how to build Vaadin applications with a test-driven approach and how to create tests with TestBench. It also shows tips for tackling widgetset complications in Maven, how to auto-reload changes in code, and how to block uncatchable exceptions in the production mode.

Chapter 12, Fun, describes three fun-oriented recipes. In this chapter, we will put to use everything we have learned in the previous recipes. We will also learn how to use the PlayingCards add-on and also learn to alert the user before closing the web page.

What you need for this book

Vaadin 7: https://vaadin.com/download

One of these IDEs:

Any web browser, for example:

The Java programming language:

Other technologies used in some recipes:

Who this book is for

This book is for developers who want to create Rich Internet Applications with Vaadin.

Both newcomers to Vaadin and those who have some experience with it will find recipes to expand their working knowledge of Vaadin.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Now we can try to change the code inside the HellovaadinUI class, so the application prints out the name of the system user."

A block of code is set as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>Vaadin Web Application</display-name>
    <context-param>
        <description>Vaadin production mode</description>
        <param-name>productionMode</param-name>
        <param-value>false</param-value>
    </context-param>
    <servlet>
     <servlet-name>Vaadin Application Servlet</servlet-name>
     <servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
     <init-param>
        <description>Vaadin UI to display</description>
        <param-name>UI</param-name>
        <param-value>app.MyVaadinUI</param-value>
     </init-param>
    </servlet>
    <servlet-mapping>
      <servlet-name>Vaadin Application Servlet</servlet-name>
      <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "There should be a few Vaadin wizards listed. Choose Vaadin 7 Project and click on the Next button."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.