aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>2008-10-24 18:45:29 +0000
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>2008-10-24 18:45:29 +0000
commitc18a2cdc0225291a25076997808db922cb1a8807 (patch)
treea34e55c9f1e494fd9303867b83bc677c1756a2ae /src
parent6ed1879a931f12218f759b880fddf37fae778f72 (diff)
downloadvaadin-framework-c18a2cdc0225291a25076997808db922cb1a8807.tar.gz
vaadin-framework-c18a2cdc0225291a25076997808db922cb1a8807.zip
Sorted out small bugs in FormExample
svn changeset:5726/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/demo/featurebrowser/FormExample.java33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/com/itmill/toolkit/demo/featurebrowser/FormExample.java b/src/com/itmill/toolkit/demo/featurebrowser/FormExample.java
index ebbd01cccc..9de2860ead 100644
--- a/src/com/itmill/toolkit/demo/featurebrowser/FormExample.java
+++ b/src/com/itmill/toolkit/demo/featurebrowser/FormExample.java
@@ -1,6 +1,6 @@
package com.itmill.toolkit.demo.featurebrowser;
-import com.itmill.toolkit.data.Container;
+import com.itmill.toolkit.data.Item;
import com.itmill.toolkit.data.Validator;
import com.itmill.toolkit.data.util.BeanItem;
import com.itmill.toolkit.ui.BaseFieldFactory;
@@ -84,7 +84,7 @@ public class FormExample extends CustomComponent {
// Ensure that the fields are shown in correct order as the
// datamodel does not force any specific order.
- setVisibleItemProperties(new String[] { "name", "address",
+ setVisibleItemProperties(new String[] { "name", "streetAddress",
"postalCode", "city" });
// For examples sake, customize some of the form fields directly
@@ -92,9 +92,8 @@ public class FormExample extends CustomComponent {
// above.
getField("name").setRequired(true);
getField("name").setRequiredError("Name is missing");
- getField("address").setRequired(true); // No error message
+ getField("streetAddress").setRequired(true); // No error message
replaceWithSelect("city", cities, cities).setNewItemsAllowed(true);
- getField("address").setCaption("Street Address");
// Set the form to act immediately on user input. This is
// automatically transports data between the client and the server
@@ -114,17 +113,17 @@ public class FormExample extends CustomComponent {
*/
static class MyFieldFactory extends BaseFieldFactory {
- public Field createField(Container container, Object itemId,
- Object propertyId, Component uiContext) {
+ public Field createField(Item item, Object propertyId,
+ Component uiContext) {
+
+ Field field = super.createField(item, propertyId, uiContext);
if ("postalCode".equals(propertyId)) {
- TextField postalCode = new TextField("Postal Code");
- postalCode.setColumns(5);
- postalCode.addValidator(new PostalCodeValidator());
- return postalCode;
+ ((TextField) field).setColumns(5);
+ field.addValidator(new PostalCodeValidator());
}
- return super.createField(container, itemId, propertyId, uiContext);
+ return field;
}
}
@@ -158,12 +157,12 @@ public class FormExample extends CustomComponent {
*/
public static class Address {
String name = "";
- String address = "";
+ String streetAddress = "";
String postalCode = "";
String city;
public String getAddressAsText() {
- return name + "\n" + address + "\n" + postalCode + " "
+ return name + "\n" + streetAddress + "\n" + postalCode + " "
+ (city == null ? "" : city);
}
@@ -175,12 +174,12 @@ public class FormExample extends CustomComponent {
return name;
}
- public void setAddress(String address) {
- this.address = address;
+ public void setStreetAddress(String address) {
+ streetAddress = address;
}
- public String getAddress() {
- return address;
+ public String getStreetAddress() {
+ return streetAddress;
}
public void setPostalCode(String postalCode) {