diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-04-27 12:38:30 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-04-27 12:38:30 +0000 |
commit | 1cdee780f301db03e7222ebe1a1824196f6882ac (patch) | |
tree | 8785d87c3aa1198d506bad4095faea5f257dd6bf /src | |
parent | b98ddbb34a1a28dc8fd80b077c28084380590a71 (diff) | |
download | vaadin-framework-1cdee780f301db03e7222ebe1a1824196f6882ac.tar.gz vaadin-framework-1cdee780f301db03e7222ebe1a1824196f6882ac.zip |
fixes #6724
Also removed old focusing hack required for ancient non supported browsers only. Latest Operas and Safari's from 3.x work fine without it.
svn changeset:18502/svn branch:6.6
Diffstat (limited to 'src')
4 files changed, 32 insertions, 21 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index 9e062eee80..72e8afe8b3 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -41,6 +41,7 @@ public class ApplicationConfiguration implements EntryPoint { private String appUri; private JavaScriptObject versionInfo; private String windowName; + private boolean standalone; private String communicationErrorCaption; private String communicationErrorMessage; private String communicationErrorUrl; @@ -95,6 +96,14 @@ public class ApplicationConfiguration implements EntryPoint { id = appId; } + /** + * @return true if the application is served by std. Vaadin servlet and is + * considered to be the only or main content of the host page. + */ + public boolean isStandalone() { + return standalone; + } + public void setInitialWindowName(String name) { windowName = name; } @@ -168,6 +177,9 @@ public class ApplicationConfiguration implements EntryPoint { if (jsobj.portletUidlURLBase) { this.@com.vaadin.terminal.gwt.client.ApplicationConfiguration::portletUidlURLBase = jsobj.portletUidlURLBase; } + if (jsobj.standalone) { + this.@com.vaadin.terminal.gwt.client.ApplicationConfiguration::standalone = true; + } } else { $wnd.alert("Vaadin app failed to initialize: " + this.id); } diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index d5d9578bd9..bc86b18daa 100755 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -171,7 +171,7 @@ public class ApplicationConnection { initializeClientHooks(); - view.init(cnf.getRootPanelId()); + view.init(cnf.getRootPanelId(), this); showLoadingIndicator(); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index 2858137517..9f1acb52fe 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -680,7 +680,8 @@ public class VView extends SimplePanel implements Container, ResizeHandler, return windows; } - public void init(String rootPanelId) { + public void init(String rootPanelId, + ApplicationConnection applicationConnection) { DOM.sinkEvents(getElement(), Event.ONKEYDOWN | Event.ONSCROLL); // iview is focused when created so element needs tabIndex @@ -698,25 +699,11 @@ public class VView extends SimplePanel implements Container, ResizeHandler, root.add(this); - BrowserInfo browser = BrowserInfo.get(); - - // set focus to iview element by default to listen possible keyboard - // shortcuts - if (browser.isOpera() || browser.isSafari() - && browser.getWebkitVersion() < 526) { - // old webkits don't support focusing div elements - Element fElem = DOM.createInputCheck(); - DOM.setStyleAttribute(fElem, "margin", "0"); - DOM.setStyleAttribute(fElem, "padding", "0"); - DOM.setStyleAttribute(fElem, "border", "0"); - DOM.setStyleAttribute(fElem, "outline", "0"); - DOM.setStyleAttribute(fElem, "width", "1px"); - DOM.setStyleAttribute(fElem, "height", "1px"); - DOM.setStyleAttribute(fElem, "position", "absolute"); - DOM.setStyleAttribute(fElem, "opacity", "0.1"); - DOM.appendChild(getElement(), fElem); - fElem.focus(); - } else { + if (applicationConnection.getConfiguration().isStandalone()) { + // set focus to iview element by default to listen possible keyboard + // shortcuts. For embedded applications this is unacceptable as we + // don't want to steal focus from the main page nor we don't want + // side-effects from focusing (scrollIntoView). getElement().focus(); } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 6752f6013b..8a39b0307e 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -1854,6 +1854,9 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements page.write("windowName: \"" + JsonPaintTarget.escapeJSON(window.getName()) + "\", "); } + if (isStandalone()) { + page.write("standalone: true, "); + } page.write("themeUri:"); page.write(themeUri != null ? "\"" + themeUri + "\"" : "null"); page.write(", versionInfo : {vaadinVersion:\""); @@ -1928,6 +1931,15 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } /** + * @return true if the served application is considered to be the only or + * main content of the host page. E.g. various embedding solutions + * should override this to false. + */ + protected boolean isStandalone() { + return true; + } + + /** * * Method to open the body tag of the html kickstart page. * <p> |