From 9ba4e15b677d42918eae32a08a6d6a2b12ff43e9 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Mon, 9 Nov 2015 12:58:52 +0200 Subject: [PATCH] Request ComboBox pages with RPC (#19929) All client to server communication of ComboBox is now done with RPC. There is still an empty changeVariables() methods to override the default behavior in AbstractSelect. Change-Id: Ic11ea48cac1846272609f6e4107bb0006d18494c --- .../client/ui/combobox/ComboBoxConnector.java | 8 ++----- server/src/com/vaadin/ui/ComboBox.java | 24 +++++++++++-------- .../shared/ui/combobox/ComboBoxServerRpc.java | 11 +++++++++ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java index 5c22e684f8..87f24845ab 100644 --- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -392,8 +392,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements */ public void requestFirstPage() { sendSelection(null); - getConnection().updateVariable(getConnectorId(), "filter", "", false); - getConnection().updateVariable(getConnectorId(), "page", 0, true); + requestPage("", 0); } /** @@ -410,10 +409,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements * the page number to get */ public void requestPage(String filter, int page) { - getConnection().updateVariable(getConnectorId(), "filter", filter, - false); - getConnection().updateVariable(getConnectorId(), "page", page, - immediate); + rpc.requestPage(filter, page); } /** diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java index dc064e925b..de87ea0d17 100644 --- a/server/src/com/vaadin/ui/ComboBox.java +++ b/server/src/com/vaadin/ui/ComboBox.java @@ -103,6 +103,19 @@ public class ComboBox extends AbstractSelect implements } } } + + @Override + public void requestPage(String filter, int page) { + filterstring = filter; + if (filterstring != null) { + filterstring = filterstring.toLowerCase(getLocale()); + } + currentPage = page; + + // TODO this should trigger a data-only update instead of a full + // repaint + requestRepaint(); + } }; FocusAndBlurServerRpcImpl focusBlurRpc = new FocusAndBlurServerRpcImpl(this) { @@ -718,16 +731,7 @@ public class ComboBox extends AbstractSelect implements // Not calling super.changeVariables due the history of select // component hierarchy - String newFilter; - if ((newFilter = (String) variables.get("filter")) != null) { - // this is a filter request - currentPage = ((Integer) variables.get("page")).intValue(); - filterstring = newFilter; - if (filterstring != null) { - filterstring = filterstring.toLowerCase(getLocale()); - } - requestRepaint(); - } + // all the client to server requests are now handled by RPC } @Override diff --git a/shared/src/com/vaadin/shared/ui/combobox/ComboBoxServerRpc.java b/shared/src/com/vaadin/shared/ui/combobox/ComboBoxServerRpc.java index 38704b5169..863aadcbcd 100644 --- a/shared/src/com/vaadin/shared/ui/combobox/ComboBoxServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/combobox/ComboBoxServerRpc.java @@ -39,4 +39,15 @@ public interface ComboBoxServerRpc extends ServerRpc { * the id of a single item or null to deselect the current value */ public void setSelectedItem(String item); + + /** + * Request the server to send a page of the item list. + * + * @param filter + * filter string interpreted according to the current filtering + * mode + * @param page + * zero based page number + */ + public void requestPage(String filter, int page); } -- 2.39.5