diff options
author | Artur Signell <artur@vaadin.com> | 2015-05-01 19:44:40 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-05-19 06:45:45 +0000 |
commit | d63bf2c215831dcfea060331339199cc086d78f7 (patch) | |
tree | b077f4c2f3702680c56fcff5a64a57169b3d776e /server/src/com/vaadin/ui | |
parent | 851306745e0974669403ea0e9d07b08e9fbf979a (diff) | |
download | vaadin-framework-d63bf2c215831dcfea060331339199cc086d78f7.tar.gz vaadin-framework-d63bf2c215831dcfea060331339199cc086d78f7.zip |
Make fields with validators immediate (#13709)7.5.0.beta1
Change-Id: I113aa38869cf4dceec24315e70d3b44eae526f65
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractComponent.java | 20 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/AbstractField.java | 18 |
2 files changed, 38 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index fd8a72ee23..27d97d5e03 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -405,6 +405,26 @@ public abstract class AbstractComponent extends AbstractClientConnector } } + /** + * Returns the explicitly set immediate value. + * + * @return the explicitly set immediate value or null if + * {@link #setImmediate(boolean)} has not been explicitly invoked + */ + protected Boolean getExplicitImmediateValue() { + return explicitImmediateValue; + } + + /** + * Returns the immediate mode of the component. + * <p> + * Certain operations such as adding a value change listener will set the + * component into immediate mode if {@link #setImmediate(boolean)} has not + * been explicitly called with false. + * + * @return true if the component is in immediate mode (explicitly or + * implicitly set), false if the component if not in immediate mode + */ public boolean isImmediate() { if (explicitImmediateValue != null) { return explicitImmediateValue; diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 5c02c9e5fb..cf14d1cb96 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -1745,6 +1745,24 @@ public abstract class AbstractField<T> extends AbstractComponent implements } } + /** + * {@inheritDoc} + * <p> + * Fields are automatically set to immediate if validators have been added. + */ + @Override + public boolean isImmediate() { + if (getExplicitImmediateValue() != null) { + return getExplicitImmediateValue(); + } + // Make field immediate when there is some kind of validation present + // (validator or required). This will avoid the UI being in a wrong + // state, e.g. user entered valid data but old validation error is still + // shown + return super.isImmediate() || !getValidators().isEmpty() + || isRequired(); + } + /* * (non-Javadoc) * |