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

Binding a container to a component


It is easy and quick to create a table in Vaadin. Because Table is managed using the data model through the Container, we don't need to care about table rendering. We can manage only the Container and Vaadin provides other stuff such as nice default CSS style, sorting values by clicking on the head of the column, resizing width of columns by the mouse, and other great functions. In relation to the previous recipe, Container is a set of Items. In this recipe, we will show how to quickly and easily create a table by Vaadin Container.

How to do it...

Carry out the following steps to bind a container to a component:

  1. Create a Vaadin project with main UI class named Demo.

    public class Demo extends UI {…}
  2. First, we need some Java Bean. For example, we can create a Product bean that is usually defined by id, name, and price. For each variable, we create the getter and setter methods.

    public class Product {
      private int id;
      private String name;
      private double price...