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

Responding immediately to an event in TextArea


It is very useful when surrounding components immediately respond to user input. For example, we can notify the user that the text in the editor has been changed. We will create a simple text area and button for saving. The button is enabled only if the value in the text area was changed as shown in the following screenshot:

How to do it...

Carry out the following steps to create a TextArea that will immediately send an event respond:

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

    public class Demo extends UI {…}
  2. We insert our text area and button to the VerticalLayout class. We start with creating a class named ImmediatelyTextArea which extends the VerticalLayout class.

    public class ImmediatelyTextArea extends VerticalLayout{…}
  3. In the constructor, we create an instance of the TextArea class. We set this component to the immediate mode and the text change event to eager mode. It causes all text changes to be immediately fired...