diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-01-02 15:52:37 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-01-02 15:52:37 +0200 |
commit | 43184719496a21d6d8c2d8c1dc9524b180893892 (patch) | |
tree | 3a22a259fc15e9d2d198ba6230fbae569bc11e14 /tests | |
parent | 23aa194c32ef713f2c775163fa424eafe1f9f6e2 (diff) | |
download | vaadin-framework-43184719496a21d6d8c2d8c1dc9524b180893892.tar.gz vaadin-framework-43184719496a21d6d8c2d8c1dc9524b180893892.zip |
Updated mini tutorial to use precreated fields
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testbench/com/vaadin/tests/minitutorials/FormUsingExistingLayout.java | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/FormUsingExistingLayout.java b/tests/testbench/com/vaadin/tests/minitutorials/FormUsingExistingLayout.java index 8ab2dafb30..9d20867d24 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/FormUsingExistingLayout.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/FormUsingExistingLayout.java @@ -1,7 +1,5 @@ package com.vaadin.tests.minitutorials; -import com.vaadin.data.Item; -import com.vaadin.data.fieldgroup.Caption; import com.vaadin.data.fieldgroup.FieldGroup; import com.vaadin.data.fieldgroup.PropertyId; import com.vaadin.data.util.BeanItem; @@ -51,29 +49,20 @@ public class FormUsingExistingLayout extends AbstractTestRoot { } public static class MyFormLayout extends GridLayout { - private TextField firstName; - private TextField lastName; + private TextField firstName = new TextField("First name"); + private TextField lastName = new TextField("Last name"); // The name of the property is by default the name of the member field, // but it can be redefined with the @PropertyId annotation @PropertyId("message") - // The field caption is by default derived from the property id, but can - // be redefined with the @Caption annotation - @Caption("Your message") - private TextArea messageField; + private TextArea messageField = new TextArea("Your message"); - public MyFormLayout(Item item) { + public MyFormLayout() { // Set up the GridLayout super(2, 3); setSpacing(true); - // Create a field group - final FieldGroup fieldGroup = new FieldGroup(item); - - // Create and bind fields for the item and inject the fields to this - fieldGroup.buildAndBindMemberFields(this); - - // The fields have been initialized and can be added to the layout + // Add the (currently unbound) fields addComponent(firstName); addComponent(lastName); @@ -85,8 +74,15 @@ public class FormUsingExistingLayout extends AbstractTestRoot { @Override protected void setup(WrappedRequest request) { - addComponent(new MyFormLayout(new BeanItem<Notice>(new Notice("John", - "Doe", "")))); + // Create the layout + MyFormLayout myFormLayout = new MyFormLayout(); + + // Create a field group and use it to bind the fields in the layout + FieldGroup fieldGroup = new FieldGroup(new BeanItem<Notice>(new Notice( + "John", "Doe", ""))); + fieldGroup.bindMemberFields(myFormLayout); + + addComponent(myFormLayout); } @Override |