aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/declarative
diff options
context:
space:
mode:
authorMatti Hosio <mhosio@vaadin.com>2014-12-17 14:08:59 +0200
committerArtur Signell <artur@vaadin.com>2014-12-17 12:51:14 +0000
commit6d75a89e8d16e0fd1370fe080a5b5b78d1f4679d (patch)
tree0a7224c3008b3dca20b4de453cb346554be1735c /server/src/com/vaadin/ui/declarative
parent7818595589e73b3da119d3c51e3950515f900bb6 (diff)
downloadvaadin-framework-6d75a89e8d16e0fd1370fe080a5b5b78d1f4679d.tar.gz
vaadin-framework-6d75a89e8d16e0fd1370fe080a5b5b78d1f4679d.zip
Do not throw exception when trying to bind a preinitialized instance field (#7749)
Change-Id: I8b40e667d03b63e05f006e7cedf108345591d118
Diffstat (limited to 'server/src/com/vaadin/ui/declarative')
-rw-r--r--server/src/com/vaadin/ui/declarative/DesignContext.java9
-rw-r--r--server/src/com/vaadin/ui/declarative/FieldBinder.java15
2 files changed, 13 insertions, 11 deletions
diff --git a/server/src/com/vaadin/ui/declarative/DesignContext.java b/server/src/com/vaadin/ui/declarative/DesignContext.java
index 25765611aa..0ce269261b 100644
--- a/server/src/com/vaadin/ui/declarative/DesignContext.java
+++ b/server/src/com/vaadin/ui/declarative/DesignContext.java
@@ -437,11 +437,12 @@ public class DesignContext implements Serializable {
* at the given component. Also registers the componentid, localId and
* caption of the given component and all its children to the context
*
- *
* @param component
* The component to be synchronized from design
* @param componentDesign
* The html tree node containing the description of the component
+ * @throws DesignException
+ * if the design contains duplicate local or global ids
*/
public void synchronizeAndRegister(Component component,
Element componentDesign) {
@@ -463,7 +464,11 @@ public class DesignContext implements Serializable {
// from the attributes of componentDesign
if (attributes.hasKey(LOCAL_ID_ATTRIBUTE)) {
String localId = attributes.get(LOCAL_ID_ATTRIBUTE);
- mapLocalId(localId, component); // two-way map
+ boolean mappingExists = mapLocalId(localId, component);
+ if (mappingExists) {
+ throw new DesignException(
+ "the following local id is not unique: " + localId);
+ }
}
// caption: a property of a component, possibly not unique
String caption = component.getCaption();
diff --git a/server/src/com/vaadin/ui/declarative/FieldBinder.java b/server/src/com/vaadin/ui/declarative/FieldBinder.java
index af82d9c58c..fcc78db414 100644
--- a/server/src/com/vaadin/ui/declarative/FieldBinder.java
+++ b/server/src/com/vaadin/ui/declarative/FieldBinder.java
@@ -135,8 +135,6 @@ public class FieldBinder implements Serializable {
/**
* Tries to bind the given {@link Component} instance to a member field of
* the bind target. The fields are matched based on localId, id and caption.
- * If a field is already bound (not null), {@link FieldBindingException} is
- * thrown.
*
* @param instance
* the instance to be bound to a field
@@ -197,14 +195,13 @@ public class FieldBinder implements Serializable {
Object fieldValue = ReflectTools.getJavaFieldValue(bindTarget,
field);
if (fieldValue != null) {
- getLogger().severe(
- "The field with identifier \"" + identifier
- + "\" already mapped");
- throw new FieldBindingException(
- "Duplicate identifier found for a field: " + fieldName);
+ getLogger().fine(
+ "The field \"" + fieldName
+ + "\" was already mapped. Ignoring.");
+ } else {
+ // set the field value
+ ReflectTools.setJavaFieldValue(bindTarget, field, instance);
}
- // set the field value
- ReflectTools.setJavaFieldValue(bindTarget, field, instance);
return true;
} catch (IllegalAccessException e) {
throw new FieldBindingException("Field binding failed", e);