summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/Label.java
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-21 17:13:10 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-22 15:03:20 +0000
commit57c7a515e0f8b12dfe23b40a10e2f384fb409708 (patch)
tree28da6f4af9a40d3a84b7ff18e551f826f2277998 /server/src/com/vaadin/ui/Label.java
parentf3ea43e76a9f28e846c9d9ba5e07fe000329dba1 (diff)
downloadvaadin-framework-57c7a515e0f8b12dfe23b40a10e2f384fb409708.tar.gz
vaadin-framework-57c7a515e0f8b12dfe23b40a10e2f384fb409708.zip
Update value when field/label local changes (#8192)
Change-Id: Ifbb426f7aee107db0be555c5ab1ef0b5f4948e5e
Diffstat (limited to 'server/src/com/vaadin/ui/Label.java')
-rw-r--r--server/src/com/vaadin/ui/Label.java33
1 files changed, 29 insertions, 4 deletions
diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java
index db5bc2862d..1cc18d33bc 100644
--- a/server/src/com/vaadin/ui/Label.java
+++ b/server/src/com/vaadin/ui/Label.java
@@ -17,6 +17,7 @@
package com.vaadin.ui;
import java.lang.reflect.Method;
+import java.util.Locale;
import java.util.logging.Logger;
import com.vaadin.data.Property;
@@ -174,8 +175,8 @@ public class Label extends AbstractComponent implements Property<String>,
}
/**
- * Returns the current value of the data source. Assumes there is a data
- * source.
+ * Returns the current value of the data source converted using the current
+ * locale.
*
* @return
*/
@@ -412,10 +413,34 @@ public class Label extends AbstractComponent implements Property<String>,
*/
@Override
public void valueChange(Property.ValueChangeEvent event) {
+ updateValueFromDataSource();
+ }
+
+ private void updateValueFromDataSource() {
// Update the internal value from the data source
- getState().text = getValue();
+ String newConvertedValue = getDataSourceValue();
+ if (!AbstractField.equals(newConvertedValue, getState().text)) {
+ getState().text = newConvertedValue;
+ fireValueChange();
+ }
+ }
- fireValueChange();
+ @Override
+ public void attach() {
+ super.attach();
+ localeMightHaveChanged();
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ super.setLocale(locale);
+ localeMightHaveChanged();
+ }
+
+ private void localeMightHaveChanged() {
+ if (getPropertyDataSource() != null) {
+ updateValueFromDataSource();
+ }
}
private String getComparableValue() {