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

Inserting a button to remove a table row


When we are working with tables, we can use a useful feature for generating columns. In Vaadin, a table is created according to the Container that is used as a data source. If we use the BeanItemContainer class, then for each field in the container bean one column is generated. So, if we want to add an other column, we can generate it using the Table.addGeneratedColumn() method. This generated column exists only in the Table, not as a property in the underlying Container. We will use it for generating buttons that remove a current row, as shown in the following screenshot:

How to do it...

Carry out the following steps to learn how to insert a new column in the table:

  1. We create a Vaadin project with the main UI class called Demo as follows:

    public class Demo extends UI {…}
  2. Our table will be a list of some products with prices. Therefore, we start with bean Product. This bean consists of name and price. We create an appropriate constructor and we also...