diff options
author | Leif Åstrand <leif@vaadin.com> | 2015-06-14 15:36:33 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-06-17 12:32:18 +0000 |
commit | f8aacf7c53d2e758e431588f44185b583fad8cb6 (patch) | |
tree | fbf8ce2cb80546eec99ef45f720137e1bf26f1b9 /server | |
parent | 02d548fb26eb2bab1ee651abce647b562600d160 (diff) | |
download | vaadin-framework-f8aacf7c53d2e758e431588f44185b583fad8cb6.tar.gz vaadin-framework-f8aacf7c53d2e758e431588f44185b583fad8cb6.zip |
Allow beforeClientResponse to change hierarchy or dirtyness (#18268)
Change-Id: I6a1ae23c1dd67f8889479a1069f260fa736bbd83
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/ClientConnector.java | 4 | ||||
-rw-r--r-- | server/src/com/vaadin/server/communication/UidlWriter.java | 38 |
2 files changed, 29 insertions, 13 deletions
diff --git a/server/src/com/vaadin/server/ClientConnector.java b/server/src/com/vaadin/server/ClientConnector.java index b784aa5d35..63483bc254 100644 --- a/server/src/com/vaadin/server/ClientConnector.java +++ b/server/src/com/vaadin/server/ClientConnector.java @@ -256,10 +256,6 @@ public interface ClientConnector extends Connector { * client. Gives the connector an opportunity to set computed/dynamic state * values or to invoke last minute RPC methods depending on other component * features. - * <p> - * This method must not alter the component hierarchy in any way. Calling - * {@link #markAsDirty()} from this method will have no effect. - * </p> * * @param initial * <code>true</code> if the client-side connector will be created diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java index 3b2caba55b..00a65d3877 100644 --- a/server/src/com/vaadin/server/communication/UidlWriter.java +++ b/server/src/com/vaadin/server/communication/UidlWriter.java @@ -23,7 +23,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -81,22 +83,40 @@ public class UidlWriter implements Serializable { // to write out service.runPendingAccessTasks(session); - ArrayList<ClientConnector> dirtyVisibleConnectors = ui - .getConnectorTracker().getDirtyVisibleConnectors(); + Set<ClientConnector> processedConnectors = new HashSet<ClientConnector>(); + LegacyCommunicationManager manager = session.getCommunicationManager(); // Paints components ConnectorTracker uiConnectorTracker = ui.getConnectorTracker(); getLogger().log(Level.FINE, "* Creating response to client"); + while (true) { + ArrayList<ClientConnector> connectorsToProcess = new ArrayList<ClientConnector>(); + for (ClientConnector c : uiConnectorTracker.getDirtyConnectors()) { + if (!processedConnectors.contains(c) + && LegacyCommunicationManager + .isConnectorVisibleToClient(c)) { + connectorsToProcess.add(c); + } + } + + if (connectorsToProcess.isEmpty()) { + break; + } + + for (ClientConnector connector : connectorsToProcess) { + boolean initialized = uiConnectorTracker + .isClientSideInitialized(connector); + processedConnectors.add(connector); + + connector.beforeClientResponse(!initialized); + } + } + getLogger().log( Level.FINE, - "Found " + dirtyVisibleConnectors.size() + "Found " + processedConnectors.size() + " dirty connectors to paint"); - for (ClientConnector connector : dirtyVisibleConnectors) { - boolean initialized = uiConnectorTracker - .isClientSideInitialized(connector); - connector.beforeClientResponse(!initialized); - } uiConnectorTracker.setWritingResponse(true); try { @@ -292,7 +312,7 @@ public class UidlWriter implements Serializable { session.getDragAndDropService().printJSONResponse(writer); - for (ClientConnector connector : dirtyVisibleConnectors) { + for (ClientConnector connector : processedConnectors) { uiConnectorTracker.markClientSideInitialized(connector); } |