diff options
author | Mikael Grankvist <mgrankvi@vaadin.com> | 2012-11-14 15:23:52 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-11-20 13:31:39 +0000 |
commit | 98555d0eac757e738b9218cd0d8b719dd37ccc05 (patch) | |
tree | 106276222f83863b4f0e205ada39d6f698efdf1e | |
parent | 64075d9078052c5ac9446d6aab2debe8a46ccfba (diff) | |
download | vaadin-framework-98555d0eac757e738b9218cd0d8b719dd37ccc05.tar.gz vaadin-framework-98555d0eac757e738b9218cd0d8b719dd37ccc05.zip |
Added getState(boolean) to allow getState without side effects (#10006)
Change-Id: Idee529a8efc245da88192cd059c9e35165d1adad
-rw-r--r-- | server/src/com/vaadin/server/AbstractClientConnector.java | 39 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/AbstractComponent.java | 2 |
2 files changed, 34 insertions, 7 deletions
diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java index 3762e90d05..ecdab22160 100644 --- a/server/src/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/com/vaadin/server/AbstractClientConnector.java @@ -158,17 +158,44 @@ public abstract class AbstractClientConnector implements ClientConnector, registerRpc(implementation, type); } + /** + * Returns the shared state for this connector. The shared state object is + * shared between the server connector and the client connector. Changes are + * only communicated from the server to the client and not in the other + * direction. + * <p> + * As a side effect, marks the connector dirty so any changes done to the + * state will be sent to the client. Use {@code getState(false)} to avoid + * marking the connector as dirty. + * </p> + * + * @return The shared state for this connector. Never null. + */ protected SharedState getState() { + return getState(true); + } + + /** + * Returns the shared state for this connector. + * + * @param markAsDirty + * true if the connector should automatically be marked dirty, + * false otherwise + * + * @return The shared state for this connector. Never null. + * @see #getState() + */ + protected SharedState getState(boolean markAsDirty) { if (null == sharedState) { sharedState = createState(); } - - UI uI = getUI(); - if (uI != null && !uI.getConnectorTracker().isWritingResponse() - && !uI.getConnectorTracker().isDirty(this)) { - markAsDirty(); + if (markAsDirty) { + UI ui = getUI(); + if (ui != null && !ui.getConnectorTracker().isWritingResponse() + && !ui.getConnectorTracker().isDirty(this)) { + markAsDirty(); + } } - return sharedState; } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 7e7a595a2e..f1924692ba 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -323,7 +323,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public boolean isEnabled() { - return getState().enabled; + return getState(false).enabled; } /* |