aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2015-11-05 13:29:15 +0200
committerArtur Signell <artur@vaadin.com>2016-08-08 08:23:59 +0000
commit07292fe8fb7b9d9cf94dd3a57cfab4e6e31bd639 (patch)
treedb420094268dbf97e902f57420b7627d097f9e09
parent9207d3f3442a6ab6b9fda29d8a76e2bee4929ab1 (diff)
downloadvaadin-framework-07292fe8fb7b9d9cf94dd3a57cfab4e6e31bd639.tar.gz
vaadin-framework-07292fe8fb7b9d9cf94dd3a57cfab4e6e31bd639.zip
Send ComboBox focus/blur with RPC (#19929)
Send focus and blur events using RPC instead of in UIDL. This change does not use ConnectorFocusAndBlurHandler to preserve old timings. Change-Id: I02a86dcc3959388ca835798a33cb600898b19ab9
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VFilterSelect.java15
-rw-r--r--client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java47
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java17
3 files changed, 61 insertions, 18 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java b/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java
index 3ec1c4d1d0..677e6f846e 100644
--- a/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java
@@ -2217,9 +2217,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
// If a focus event is not going to be sent, send the options
// request immediately; otherwise queue in the same burst as the
// focus event. Fixes #8321.
- ApplicationConnection client = connector.getConnection();
boolean immediate = focused
- || !client.hasEventListeners(this, EventId.FOCUS);
+ || !connector.hasEventListener(EventId.FOCUS);
filterOptions(-1, "", immediate);
popupOpenerClicked = true;
lastFilter = "";
@@ -2314,14 +2313,12 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
}
addStyleDependentName("focus");
- ApplicationConnection client = connector.getConnection();
- if (client.hasEventListeners(this, EventId.FOCUS)) {
- client.updateVariable(paintableId, EventId.FOCUS, "", true);
+ if (connector.sendFocusEvent()) {
afterUpdateClientVariables();
}
- client.getVTooltip().showAssistive(
- connector.getTooltipInfo(getElement()));
+ connector.getConnection().getVTooltip()
+ .showAssistive(connector.getTooltipInfo(getElement()));
}
/**
@@ -2383,9 +2380,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
}
removeStyleDependentName("focus");
- ApplicationConnection client = connector.getConnection();
- if (client.hasEventListeners(this, EventId.BLUR)) {
- client.updateVariable(paintableId, EventId.BLUR, "", true);
+ if (connector.sendBlurEvent()) {
afterUpdateClientVariables();
}
}
diff --git a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java
index f66a115313..c4a9856311 100644
--- a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java
@@ -31,6 +31,8 @@ import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.VFilterSelect;
import com.vaadin.client.ui.VFilterSelect.FilterSelectSuggestion;
+import com.vaadin.shared.EventId;
+import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.combobox.ComboBoxConstants;
import com.vaadin.shared.ui.combobox.ComboBoxServerRpc;
@@ -45,6 +47,9 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
protected ComboBoxServerRpc rpc = RpcProxy.create(ComboBoxServerRpc.class,
this);
+ protected FocusAndBlurServerRpc focusAndBlurRpc = RpcProxy.create(
+ FocusAndBlurServerRpc.class, this);
+
// oldSuggestionTextMatchTheOldSelection is used to detect when it's safe to
// update textbox text by a changed item caption.
private boolean oldSuggestionTextMatchTheOldSelection;
@@ -453,4 +458,46 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
immediate);
}
+ /**
+ * Notify the server that the combo box received focus.
+ *
+ * For timing reasons, ConnectorFocusAndBlurHandler is not used at the
+ * moment.
+ *
+ * This method is for internal use only and may be removed in future
+ * versions.
+ *
+ * @since
+ * @return true if an event was sent (there are registered listeners), false
+ * otherwise
+ */
+ public boolean sendFocusEvent() {
+ boolean registeredListeners = hasEventListener(EventId.FOCUS);
+ if (registeredListeners) {
+ focusAndBlurRpc.focus();
+ }
+ return registeredListeners;
+ }
+
+ /**
+ * Notify the server that the combo box lost focus.
+ *
+ * For timing reasons, ConnectorFocusAndBlurHandler is not used at the
+ * moment.
+ *
+ * This method is for internal use only and may be removed in future
+ * versions.
+ *
+ * @since
+ * @return true if an event was sent (there are registered listeners), false
+ * otherwise
+ */
+ public boolean sendBlurEvent() {
+ boolean registeredListeners = hasEventListener(EventId.BLUR);
+ if (registeredListeners) {
+ focusAndBlurRpc.blur();
+ }
+ return registeredListeners;
+ }
+
}
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index bb87aed0bb..e6b7b2be94 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -29,6 +29,7 @@ import com.vaadin.data.util.filter.SimpleStringFilter;
import com.vaadin.event.FieldEvents;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.server.PaintException;
@@ -90,6 +91,13 @@ public class ComboBox extends AbstractSelect implements
}
};
+ FocusAndBlurServerRpcImpl focusBlurRpc = new FocusAndBlurServerRpcImpl(this) {
+ @Override
+ protected void fireEvent(Component.Event event) {
+ ComboBox.this.fireEvent(event);
+ }
+ };
+
/**
* Holds value of property pageLength. 0 disables paging.
*/
@@ -170,6 +178,7 @@ public class ComboBox extends AbstractSelect implements
*/
private void init() {
registerRpc(rpc);
+ registerRpc(focusBlurRpc);
setNewItemsAllowed(false);
setImmediate(true);
@@ -759,14 +768,6 @@ public class ComboBox extends AbstractSelect implements
}
requestRepaint();
}
-
- if (variables.containsKey(FocusEvent.EVENT_ID)) {
- fireEvent(new FocusEvent(this));
- }
- if (variables.containsKey(BlurEvent.EVENT_ID)) {
- fireEvent(new BlurEvent(this));
- }
-
}
@Override