diff options
author | Matti Tahvonen <matti@vaadin.com> | 2013-12-07 17:22:02 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-12-18 09:46:03 +0000 |
commit | 8af8d2f8c25dc1f8ced34d7ba1de727bb6f2d0ac (patch) | |
tree | 57a309fec235dc858ed44f90d74dcf71458364d8 /server/src/com/vaadin/ui/AbstractComponent.java | |
parent | 0d303da73bca604474649a83817d1b7d5e09f2e2 (diff) | |
download | vaadin-framework-8af8d2f8c25dc1f8ced34d7ba1de727bb6f2d0ac.tar.gz vaadin-framework-8af8d2f8c25dc1f8ced34d7ba1de727bb6f2d0ac.zip |
Make fields with value change listener immediate
Makes fields with value change listener immediate without explicit
call. If immediate value has been explicitly set, it is honoured.
In most cases immediate now works seamlessly and excess server
round trips should be rare as a regression.
“Fixes” #8029 in a more elegant manner
Change-Id: Ic240c78c0a29447809a17de74196d3325a78ec1f
Diffstat (limited to 'server/src/com/vaadin/ui/AbstractComponent.java')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractComponent.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index a0a87b260d..85671922a5 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -38,6 +38,7 @@ import com.vaadin.server.VaadinSession; import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ui.ComponentStateUtil; +import com.vaadin.ui.Field.ValueChangeEvent; import com.vaadin.util.ReflectTools; /** @@ -97,6 +98,8 @@ public abstract class AbstractComponent extends AbstractClientConnector private HasComponents parent; + private Boolean explicitImmediateValue; + /* Constructor */ /** @@ -361,7 +364,17 @@ public abstract class AbstractComponent extends AbstractClientConnector } public boolean isImmediate() { - return getState(false).immediate; + if (explicitImmediateValue != null) { + return explicitImmediateValue; + } else if (hasListeners(ValueChangeEvent.class)) { + /* + * Automatic immediate for fields that developers are interested + * about. + */ + return true; + } else { + return false; + } } /** @@ -372,6 +385,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * immediate mode after the call. */ public void setImmediate(boolean immediate) { + explicitImmediateValue = immediate; getState().immediate = immediate; } @@ -668,6 +682,8 @@ public abstract class AbstractComponent extends AbstractClientConnector } else { getState().errorMessage = null; } + + getState().immediate = isImmediate(); } /* General event framework */ |