aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/Label.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/com/vaadin/ui/Label.java')
-rw-r--r--server/src/com/vaadin/ui/Label.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java
index 71298289f4..b4685adcea 100644
--- a/server/src/com/vaadin/ui/Label.java
+++ b/server/src/com/vaadin/ui/Label.java
@@ -18,7 +18,6 @@ package com.vaadin.ui;
import java.lang.reflect.Method;
import java.util.Locale;
-import java.util.logging.Logger;
import com.vaadin.data.Property;
import com.vaadin.data.util.AbstractProperty;
@@ -56,9 +55,6 @@ public class Label extends AbstractComponent implements Property<String>,
Property.Viewer, Property.ValueChangeListener,
Property.ValueChangeNotifier, Comparable<Label> {
- private static final Logger logger = Logger
- .getLogger(Label.class.getName());
-
/**
* @deprecated As of 7.0, use {@link ContentMode#TEXT} instead
*/
@@ -190,7 +186,8 @@ public class Label extends AbstractComponent implements Property<String>,
/**
* Set the value of the label. Value of the label is the XML contents of the
- * label.
+ * label. Since Vaadin 7.2, changing the value of Label instance with that
+ * method will fire ValueChangeEvent.
*
* @param newStringValue
* the New value of the label.
@@ -198,7 +195,13 @@ public class Label extends AbstractComponent implements Property<String>,
@Override
public void setValue(String newStringValue) {
if (getPropertyDataSource() == null) {
- getState().text = newStringValue;
+
+ LabelState state = (LabelState) getState(false);
+ String oldTextValue = state.text;
+ if (!SharedUtil.equals(oldTextValue, newStringValue)) {
+ getState().text = newStringValue;
+ fireValueChange();
+ }
} else {
throw new IllegalStateException(
"Label is only a Property.Viewer and cannot update its data source");
@@ -227,7 +230,8 @@ public class Label extends AbstractComponent implements Property<String>,
}
/**
- * Sets the property as data-source for viewing.
+ * Sets the property as data-source for viewing. Since Vaadin 7.2 a
+ * ValueChangeEvent is fired if the new value is different from previous.
*
* @param newDataSource
* the new data source Property
@@ -257,7 +261,7 @@ public class Label extends AbstractComponent implements Property<String>,
if (dataSource != null) {
// Update the value from the data source. If data source was set to
// null, retain the old value
- getState().text = getDataSourceValue();
+ updateValueFromDataSource();
}
// Listens the new data source if possible
@@ -408,7 +412,8 @@ public class Label extends AbstractComponent implements Property<String>,
private void updateValueFromDataSource() {
// Update the internal value from the data source
String newConvertedValue = getDataSourceValue();
- if (!SharedUtil.equals(newConvertedValue, getState().text)) {
+ if (!SharedUtil.equals(newConvertedValue,
+ ((LabelState) getState(false)).text)) {
getState().text = newConvertedValue;
fireValueChange();
}