]> source.dussan.org Git - vaadin-framework.git/commitdiff
bindFields -> bindMemberFields + javadoc
authorArtur Signell <artur@vaadin.com>
Thu, 22 Dec 2011 09:06:45 +0000 (11:06 +0200)
committerArtur Signell <artur@vaadin.com>
Thu, 22 Dec 2011 10:42:01 +0000 (12:42 +0200)
src/com/vaadin/data/fieldbinder/FieldGroup.java
tests/testbench/com/vaadin/tests/fieldbinder/FormWithNestedProperties.java

index d65da43d2b63ebedea81c0be3c10ea9d83608abe..920849a289651d392936a37d2f787bb713c24bc7 100644 (file)
@@ -16,7 +16,6 @@ import com.vaadin.data.Item;
 import com.vaadin.data.Property;\r
 import com.vaadin.data.TransactionalProperty;\r
 import com.vaadin.data.Validator.InvalidValueException;\r
-import com.vaadin.data.fieldbinder.FormBuilder.FormBuilderException;\r
 import com.vaadin.data.util.TransactionalPropertyWrapper;\r
 import com.vaadin.tools.ReflectTools;\r
 import com.vaadin.ui.Field;\r
@@ -547,8 +546,10 @@ public class FieldGroup implements Serializable {
     }\r
 \r
     /**\r
-     * FIXME Javadoc\r
-     * \r
+     * CommitHandlers are used by {@link FieldGroup#commit()} as part of the\r
+     * commit transactions. CommitHandlers can perform custom operations as part\r
+     * of the commit and cause the commit to be aborted by throwing a\r
+     * {@link CommitException}.\r
      */\r
     public interface CommitHandler extends Serializable {\r
         /**\r
@@ -634,21 +635,42 @@ public class FieldGroup implements Serializable {
     }\r
 \r
     /**\r
-     * Binds fields for the given class.\r
+     * Binds member fields found in the given object.\r
+     * <p>\r
+     * This method processes all (Java) member fields whose type extends\r
+     * {@link Field} and that can be mapped to a property id. Property id\r
+     * mapping is done based on the field name or on a @{@link PropertyId}\r
+     * annotation on the field. All non-null fields for which a property id can\r
+     * be determined are bound to the property id.\r
+     * </p>\r
      * <p>\r
-     * This method processes all fields whose type extends {@link Field} and\r
-     * that can be mapped to a property id. Property id mapping is done based on\r
-     * the field name or on a {@link PropertyId} annotation on the field. All\r
-     * non-null fields for which a property id can be determined are bound to\r
-     * the property id.\r
+     * For example:\r
+     * \r
+     * <pre>\r
+     * public class MyForm extends VerticalLayout {\r
+     * private TextField firstName = new TextField("First name");\r
+     * @PropertyId("last")\r
+     * private TextField lastName = new TextField("Last name"); \r
+     * private TextField age = new TextField("Age"); ... }\r
+     * \r
+     * MyForm myForm = new MyForm(); \r
+     * ... \r
+     * fieldGroup.bindMemberFields(myForm);\r
+     * </pre>\r
      * \r
-     * @param object\r
-     *            The object to process\r
-     * @throws FormBuilderException\r
-     *             If there is a problem building or binding a field\r
+     * </p>\r
+     * This binds the firstName TextField to a "firstName" property id in the\r
+     * item, lastName TextField to a "last" property and the age TextField to a\r
+     * "age" property id.\r
+     * \r
+     * @param objectWithMemberFields\r
+     *            The object that contains (Java) member fields to bind\r
+     * @throws BindException\r
+     *             If there is a problem binding a field\r
      */\r
-    public void bindFields(Object object) throws BindException {\r
-        Class<?> objectClass = object.getClass();\r
+    public void bindMemberFields(Object objectWithMemberFields)\r
+            throws BindException {\r
+        Class<?> objectClass = objectWithMemberFields.getClass();\r
 \r
         for (java.lang.reflect.Field f : objectClass.getDeclaredFields()) {\r
 \r
@@ -683,7 +705,7 @@ public class FieldGroup implements Serializable {
             try {\r
                 // Get the field from the object\r
                 Field<?> field = (Field<?>) ReflectTools.getJavaFieldValue(\r
-                        object, f);\r
+                        objectWithMemberFields, f);\r
                 // Bind it to the property id\r
                 bind(field, propertyId);\r
             } catch (Exception e) {\r
index 69eac04d482d69e862c9dcc6cc0bb08e598fb424..637cc26a886cc95bfd4cd3a69063ee5df14bf551 100644 (file)
@@ -32,7 +32,7 @@ public class FormWithNestedProperties extends AbstractBeanFieldBinderTest {
         super.setup();\r
 \r
         setFieldBinder(new BeanFieldGroup<Person>(Person.class));\r
-        getFieldBinder().bindFields(this);\r
+        getFieldBinder().bindMemberFields(this);\r
         country = new FormBuilder(getFieldBinder()).buildAndBind("country",\r
                 "address.country", NativeSelect.class);\r
         addComponent(firstName);\r