From 150352f64cdb49a27b110bd32e049c307fcf3486 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 5 Apr 2013 18:33:55 +0300 Subject: Implemented poll interval for UI (#11495) Change-Id: Ic56b0123970f18e282c75d67863569ac55c72ea8 --- server/src/com/vaadin/ui/UI.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'server') diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 2d9f49b122..6160978542 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -148,6 +148,14 @@ public abstract class UI extends AbstractSingleComponentContainer implements UI.this.scrollTop = scrollTop; UI.this.scrollLeft = scrollLeft; } + + @Override + public void poll() { + /* + * No-op. This is only called to cause a server visit to check for + * changes. + */ + } }; /** @@ -1171,4 +1179,30 @@ public abstract class UI extends AbstractSingleComponentContainer implements public void setPushConnection(PushConnection connection) { pushConnection = connection; } + + /** + * Sets the interval with which the UI should poll the server to see if + * there are any changes. Polling is disabled by default. + *

+ * Note that it is possible to enable push and polling at the same time but + * it should not be done to avoid excessive server traffic. + *

+ * + * @param intervalInMillis + * The interval (in ms) with which the UI should poll the server + * or -1 to disable polling + */ + public void setPollInterval(int intervalInMillis) { + getState().pollInterval = intervalInMillis; + } + + /** + * Returns the interval with which the UI polls the server. + * + * @return The interval (in ms) with which the UI polls the server or -1 if + * polling is disabled + */ + public int getPollInterval() { + return getState(false).pollInterval; + } } -- cgit v1.2.3