diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/VaadinSession.java | 14 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/UI.java | 9 |
2 files changed, 16 insertions, 7 deletions
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java index 504788d479..9dedddcc2c 100644 --- a/server/src/com/vaadin/server/VaadinSession.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -885,9 +885,9 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { * Unlocks this session. This method should always be used in a finally * block after {@link #lock()} to ensure that the lock is always released. * <p> - * If {@link #getPushMode() the push mode} is {@link PushMode#AUTOMATIC - * automatic}, pushes the changes in all UIs in this session to their - * respective clients. + * For UIs in this session that have its push mode set to + * {@link PushMode#AUTOMATIC automatic}, pending changes will be pushed to + * their respective clients. * * @see #lock() * @see UI#push() @@ -904,7 +904,13 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { for (UI ui : getUIs()) { if (ui.getPushConfiguration().getPushMode() == PushMode.AUTOMATIC) { - ui.push(); + Map<Class<?>, CurrentInstance> oldCurrent = CurrentInstance + .setCurrent(ui); + try { + ui.push(); + } finally { + CurrentInstance.restoreInstances(oldCurrent); + } } } } diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 6c9551ea81..403bb31f63 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -1294,15 +1294,18 @@ public abstract class UI extends AbstractSingleComponentContainer implements * Pushes the pending changes and client RPC invocations of this UI to the * client-side. * <p> - * As with all UI methods, it is not safe to call push() without holding the - * {@link VaadinSession#lock() session lock}. + * As with all UI methods, the session must be locked when calling this + * method. It is also recommended that {@link UI#getCurrent()} is set up to + * return this UI since writing the response may invoke logic in any + * attached component or extension. The recommended way of fulfilling these + * conditions is to use {@link #access(Runnable)}. * * @throws IllegalStateException * if push is disabled. * @throws UIDetachedException * if this UI is not attached to a session. * - * @see #getPushMode() + * @see #getPushConfiguration() * * @since 7.1 */ |