aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2016-08-10 11:26:01 +0300
committerHenri Sara <hesara@vaadin.com>2016-08-11 15:34:22 +0300
commitc726ae1b276049282286db3b0934e90ac8d8a2ce (patch)
tree86cdf6ac65acd3bd6c2908652178b99c9dc6c1ae /server/src
parent81b849c1af199be481e00c86ca324cfaffe8a7a0 (diff)
downloadvaadin-framework-c726ae1b276049282286db3b0934e90ac8d8a2ce.tar.gz
vaadin-framework-c726ae1b276049282286db3b0934e90ac8d8a2ce.zip
Make immediate mode the default
Change-Id: I0a1fc0bf6f3de1b7d6975cd87cb7bb65c38dba4e
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/legacy/ui/LegacyAbstractField.java18
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractComponent.java15
-rw-r--r--server/src/main/java/com/vaadin/ui/Upload.java21
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java12
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentTest.java23
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java38
6 files changed, 53 insertions, 74 deletions
diff --git a/server/src/main/java/com/vaadin/legacy/ui/LegacyAbstractField.java b/server/src/main/java/com/vaadin/legacy/ui/LegacyAbstractField.java
index 402f1fb257..901cb78932 100644
--- a/server/src/main/java/com/vaadin/legacy/ui/LegacyAbstractField.java
+++ b/server/src/main/java/com/vaadin/legacy/ui/LegacyAbstractField.java
@@ -1798,24 +1798,6 @@ public abstract class LegacyAbstractField<T> extends AbstractComponent
}
}
- /**
- * {@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)
*
diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java
index 24f1ef098b..61cd991116 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java
@@ -39,9 +39,8 @@ import com.vaadin.event.ConnectorActionManager;
import com.vaadin.event.ContextClickEvent;
import com.vaadin.event.ContextClickEvent.ContextClickListener;
import com.vaadin.event.ContextClickEvent.ContextClickNotifier;
-import com.vaadin.legacy.ui.LegacyField;
-import com.vaadin.legacy.ui.LegacyField.ValueChangeEvent;
import com.vaadin.event.ShortcutListener;
+import com.vaadin.legacy.ui.LegacyField;
import com.vaadin.server.AbstractClientConnector;
import com.vaadin.server.AbstractErrorMessage.ContentMode;
import com.vaadin.server.ComponentSizeValidator;
@@ -455,9 +454,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
/**
* 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.
+ * Since Vaadin 8, the default mode is immediate.
*
* @return true if the component is in immediate mode (explicitly or
* implicitly set), false if the component if not in immediate mode
@@ -465,14 +462,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
public boolean isImmediate() {
if (explicitImmediateValue != null) {
return explicitImmediateValue;
- } else if (hasListeners(ValueChangeEvent.class)) {
- /*
- * Automatic immediate for fields that developers are interested
- * about.
- */
- return true;
} else {
- return false;
+ return true;
}
}
diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java
index a61bcf1bd9..0a88b40215 100644
--- a/server/src/main/java/com/vaadin/ui/Upload.java
+++ b/server/src/main/java/com/vaadin/ui/Upload.java
@@ -1194,6 +1194,27 @@ public class Upload extends AbstractComponent implements Component.Focusable,
return super.getListeners(eventType);
}
+ /**
+ * Returns the immediate mode of the component.
+ * <p>
+ * An immediate mode Upload component displays the browser file choosing
+ * button immediately, whereas a non-immediate upload only shows a Vaadin
+ * button.
+ * <p>
+ * The default mode of an Upload component is non-immediate.
+ *
+ * @return true if the component is in immediate mode, false if the
+ * component if not in immediate mode
+ */
+ @Override
+ public boolean isImmediate() {
+ if (getExplicitImmediateValue() != null) {
+ return getExplicitImmediateValue();
+ } else {
+ return false;
+ }
+ }
+
@Override
protected UploadState getState() {
return (UploadState) super.getState();
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
index 1588471395..42eccd5052 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -46,7 +46,7 @@ import com.vaadin.ui.declarative.DesignContext;
/**
* Test cases for reading and writing the properties of AbstractComponent.
- *
+ *
* @since
* @author Vaadin Ltd
*/
@@ -73,7 +73,7 @@ public class AbstractComponentDeclarativeTest extends
public void testProperties() {
String design = "<vaadin-label id=\"testId\" primary-style-name=\"test-style\" "
+ "caption=\"test-caption\" locale=\"fi_FI\" description=\"test-description\" "
- + "error=\"<div>test-error</div>\" immediate />";
+ + "error=\"<div>test-error</div>\" />";
component.setId("testId");
component.setPrimaryStyleName("test-style");
component.setCaption("test-caption");
@@ -97,7 +97,7 @@ public class AbstractComponentDeclarativeTest extends
"<vaadin-label immediate />" };
Boolean[] explicitImmediate = { null, Boolean.FALSE, Boolean.TRUE,
Boolean.TRUE };
- boolean[] immediate = { false, false, true, true };
+ boolean[] immediate = { true, false, true, true };
for (int i = 0; i < design.length; i++) {
component = (AbstractComponent) Design
.read(new ByteArrayInputStream(design[i].getBytes(Charset
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentTest.java
new file mode 100644
index 0000000000..1cc48ee3e2
--- /dev/null
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentTest.java
@@ -0,0 +1,23 @@
+package com.vaadin.tests.server.component.abstractcomponent;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.vaadin.ui.AbstractComponent;
+
+public class AbstractComponentTest {
+ AbstractComponent component = new AbstractComponent() {
+ };
+
+ @Test
+ public void testImmediate() {
+ assertTrue("Component should be immediate by default",
+ component.isImmediate());
+ component.setImmediate(false);
+ assertFalse(
+ "Explicitly non-immediate component should not be immediate",
+ component.isImmediate());
+ }
+}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java
index 47e8bc5a0e..08d8770ac4 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java
@@ -69,15 +69,6 @@ public class AbsFieldValidatorsTest {
}
@Test
- public void validatorShouldMakeImmediate() {
- assertFalse("field should not be immediate by default",
- field.isImmediate());
- field.addValidator(validator);
- assertTrue("field should be immediate when it has a validator",
- field.isImmediate());
- }
-
- @Test
public void nonImmediateFieldWithValidator() {
field.setImmediate(false);
field.addValidator(validator);
@@ -85,33 +76,4 @@ public class AbsFieldValidatorsTest {
field.isImmediate());
}
- @Test
- public void removeValidatorMakesNonImmediate() {
- field.addValidator(validator);
- field.removeValidator(validator);
- assertFalse(
- "field should be non-immediate after validator was removed",
- field.isImmediate());
- }
-
- @Test
- public void requiredMakesImmediate() {
- assertFalse("field should not be immediate by default",
- field.isImmediate());
- field.setRequired(true);
- assertTrue("field should be immediate when it is required",
- field.isImmediate());
- }
-
- @Test
- public void removeRequiredMakesNonImmediate() {
- assertFalse("field should not be immediate by default",
- field.isImmediate());
- field.setRequired(true);
- field.setRequired(false);
- assertFalse(
- "field should not be immediate even though it was required",
- field.isImmediate());
- }
-
}