summaryrefslogtreecommitdiffstats
path: root/vaadin-app
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-09-26 14:44:18 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-09-26 14:44:18 +0200
commit36b613ad4b43a177a7a6a275f8cf0feb7c2b9211 (patch)
treeca296bb8deac5469ee7f0a6d7dc143e9316423f2 /vaadin-app
parentd5b6ca708810a938b56f57beaf102d6d7319b550 (diff)
downloadskeletons-36b613ad4b43a177a7a6a275f8cf0feb7c2b9211.zip
skeletons-36b613ad4b43a177a7a6a275f8cf0feb7c2b9211.tar.gz
vaadin-app: use buttonClick validation + setComponentError
Diffstat (limited to 'vaadin-app')
-rw-r--r--vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
index 3dfe515..e69967d 100644
--- a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
+++ b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
@@ -44,7 +44,7 @@ class DataMappingLayout extends FormLayout {
//
Double trouble = 66.6;
final ObjectProperty<Double> property = new ObjectProperty<Double>(trouble);
- final TextField tf2 = new TextField("ObjectProperty", property);
+ final TextField tf2 = new TextField("ObjectProperty + Validator", property);
tf2.setImmediate(true);
tf2.addValidator( new DoubleValidator("It should be a double") );
//tf2.setValidationVisible(false); // nothing will happen
@@ -53,6 +53,22 @@ class DataMappingLayout extends FormLayout {
lb2.setCaption("The Value");
addComponent(lb2);
//
+ final TextField tf3 = new TextField("No spaces");
+ addComponent(tf3);
+ tf3.setComponentError(null); // (actually the default)
+ final Button b1 = new Button("Ok!");
+ addComponent(b1);
+ b1.addListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ if (! ((String) tf3.getValue()).matches("^\\w*$")) {
+ tf3.setComponentError(new UserError("Must be letters and numbers"));
+ } else {
+ tf3.setComponentError(null);
+ }
+ }
+ });
+ //
Button closeButton = new Button("close the application");
closeButton.setDescription("This will close the application");
addComponent(closeButton );