aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2015-11-05 13:29:15 +0200
committerHenri Sara <hesara@vaadin.com>2016-01-15 14:42:56 +0200
commitf2b9f4779defd22258cb2e0037bdfd10f4c348f4 (patch)
tree943e1b6b65bdf1538cd8d6e795f78b8358f8a74c
parent8985aef09fccc07b278a5bd082449e511bc5e511 (diff)
downloadvaadin-framework-f2b9f4779defd22258cb2e0037bdfd10f4c348f4.tar.gz
vaadin-framework-f2b9f4779defd22258cb2e0037bdfd10f4c348f4.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: I1d58756e3955a11864b1ef00abcd27525a4db593
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java15
-rw-r--r--client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java47
-rw-r--r--server/src/com/vaadin/ui/ComboBox.java17
3 files changed, 61 insertions, 18 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index 98950db746..86ef67cde6 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -1979,9 +1979,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 = "";
@@ -2076,14 +2075,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()));
}
/**
@@ -2139,9 +2136,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/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
index 35e6fff04d..646f4b8bb6 100644
--- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
+++ b/client/src/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.ComboBoxServerRpc;
import com.vaadin.shared.ui.combobox.ComboBoxState;
@@ -44,6 +46,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;
@@ -432,4 +437,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/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java
index 189cf20aab..ecc181a0f7 100644
--- a/server/src/com/vaadin/ui/ComboBox.java
+++ b/server/src/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(Event event) {
+ ComboBox.this.fireEvent(event);
+ }
+ };
+
/**
* Holds value of property pageLength. 0 disables paging.
*/
@@ -161,6 +169,7 @@ public class ComboBox extends AbstractSelect implements
*/
private void init() {
registerRpc(rpc);
+ registerRpc(focusBlurRpc);
setNewItemsAllowed(false);
setImmediate(true);
@@ -745,14 +754,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