diff options
author | John Ahlroos <john@vaadin.com> | 2012-09-20 10:06:32 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2012-09-20 10:06:32 +0300 |
commit | 96d1ba6b53c2b8380a6cb4b3b1040e291a1a8766 (patch) | |
tree | 5a40e9e3e52ed623a0511c575bb3473ff8eef4c3 | |
parent | 5fd0cda243e548448fe2b60e6693d626a7d9b734 (diff) | |
parent | c93035c9812b33718195c829a7231347e095b549 (diff) | |
download | vaadin-framework-96d1ba6b53c2b8380a6cb4b3b1040e291a1a8766.tar.gz vaadin-framework-96d1ba6b53c2b8380a6cb4b3b1040e291a1a8766.zip |
Merge branch 'master' into html5-doctype
13 files changed, 210 insertions, 22 deletions
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 70c875b10c..d752b8eb33 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -14,6 +14,22 @@ <param-value>false</param-value> <description>Vaadin production mode</description> </context-param> + <servlet> + <servlet-name>Embed App 1</servlet-name> + <servlet-class>com.vaadin.server.LegacyVaadinServlet</servlet-class> + <init-param> + <param-name>application</param-name> + <param-value>com.vaadin.tests.components.absolutelayout.AbsoluteLayoutClipping</param-value> + </init-param> + </servlet> + <servlet> + <servlet-name>Embed App 2</servlet-name> + <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> + <init-param> + <param-name>ui</param-name> + <param-value>com.vaadin.tests.components.label.MarginsInLabels</param-value> + </init-param> + </servlet> <context-param> <param-name>resourceCacheTime</param-name> @@ -34,8 +50,17 @@ <param-value>com.vaadin.tests.integration.IntegrationTestApplication</param-value> </init-param> </servlet> + <servlet-mapping> + <servlet-name>Embed App 1</servlet-name> + <url-pattern>/embed1/*</url-pattern> + </servlet-mapping> <servlet-mapping> + <servlet-name>Embed App 2</servlet-name> + <url-pattern>/embed2/*</url-pattern> + </servlet-mapping> + + <servlet-mapping> <servlet-name>VaadinApplicationRunner</servlet-name> <url-pattern>/run/*</url-pattern> </servlet-mapping> diff --git a/WebContent/statictestfiles/embed-two-uis.html b/WebContent/statictestfiles/embed-two-uis.html new file mode 100755 index 0000000000..62dff7d8d0 --- /dev/null +++ b/WebContent/statictestfiles/embed-two-uis.html @@ -0,0 +1,93 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta http-equiv="X-UA-Compatible" content="chrome=1" /> +<title>com.vaadin.tests.components.embedded.EmbeddedPdf</title> +<style type="text/css"> +html,body { + height: 100%; + margin: 0; +} +</style> +<link rel="shortcut icon" type="image/vnd.microsoft.icon" + href="/VAADIN/themes/reindeer/favicon.ico" /> +<link rel="icon" type="image/vnd.microsoft.icon" + href="/VAADIN/themes/reindeer/favicon.ico" /> + +<script type="text/javascript" src="/VAADIN/vaadinBootstrap.js"></script> +</head> +<body scroll="auto" class=" v-generated-body"> + <span>Embed 1 (AbsoluteLayoutClipping)</span> + <div style="width: 300px; height: 300px; border: 1px solid red;" + id="app1" class=" v-app v-app-VaadinServletSession"> + <div class=" v-app-loading"></div> + <noscript>You have to enable javascript in your browser to + use an application built with Vaadin.</noscript> + </div> + <iframe tabindex="-1" id="__gwt_historyFrame" + style="position: absolute; width: 0; height: 0; border: 0; overflow: hidden" + src="javascript:false"></iframe> + <script type="text/javascript"> + // + if (!window.vaadin) + alert("Failed to load the bootstrap javascript: /VAADIN/vaadinBootstrap.js"); + vaadin + .setDefaults({ + "appUri" : "/", + "authErrMsg" : { + "caption" : "Authentication problem", + "message" : "Take note of any unsaved data, and <u>click here<\/u>tagtagtag to continue." + }, + "comErrMsg" : { + "caption" : "Communication problem", + "message" : "Take note of any unsaved data, and _$t_$tag_$ere<\k here_$t_$tag_$t_$tag to continue." + }, + "debug" : true, + "heartbeatInterval" : 300, + "standalone" : true, + "widgetsetBase" : "/VAADIN/widgetsets/" + }); + </script> + + </script> + <script type="text/javascript"> + // + vaadin.initApplication("app1", { + "appUri" : "/embed1", + "initialParams" : {}, + "initialPath" : "", + "themeUri" : "/VAADIN/themes/reindeer", + "versionInfo" : { + "vaadinVersion" : "9.9.9.INTERNAL-DEBUG-BUILD" + }, + "widgetset" : "com.vaadin.DefaultWidgetSet" + }); + // + </script> + <span>Embed 2 (MarginsInLabels)</span> + <div style="width: 300px; height: 300px; border: 1px solid blue;" + id="app2" class=" v-app v-app-VaadinServletSession"> + <div class="v-app-loading"></div> + <noscript>You have to enable javascript in your browser to + use an application built with Vaadin.</noscript> + </div> + <iframe tabindex="-1" id="__gwt_historyFrame" + style="position: absolute; width: 0; height: 0; border: 0; overflow: hidden" + src="javascript:false"></iframe> + <script type="text/javascript"> + vaadin.initApplication("app2", { + "appUri" : "/embed2", + "initialParams" : {}, + "initialPath" : "/", + "themeUri" : "/VAADIN/themes/reindeer", + "versionInfo" : { + "vaadinVersion" : "9.9.9.INTERNAL-DEBUG-BUILD" + }, + "widgetset" : "com.vaadin.DefaultWidgetSet" + }); + // + </script> + +</body> +</html>
\ No newline at end of file diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java index fe0c579d73..834225edd9 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java @@ -20,25 +20,35 @@ public class WidgetInitVisitor extends TypeVisitor { public void visitConnector(TreeLogger logger, JClassType type, ConnectorBundle bundle) throws UnableToCompleteException { if (ConnectorBundle.isConnectedComponentConnector(type)) { + // The class in which createWidget is implemented JClassType createWidgetClass = findInheritedMethod(type, "createWidget").getEnclosingType(); - boolean needsCreateWidgetSupport = createWidgetClass - .getQualifiedSourceName() - .equals(AbstractComponentConnector.class.getCanonicalName()); JMethod getWidget = findInheritedMethod(type, "getWidget"); JClassType widgetType = getWidget.getReturnType().isClass(); + // Needs GWT constructor if createWidget is not overridden + if (createWidgetClass.getQualifiedSourceName().equals( + AbstractComponentConnector.class.getCanonicalName())) { + bundle.setNeedsGwtConstructor(widgetType); + + // Also needs widget type to find the right GWT constructor + bundle.setNeedsReturnType(type, getWidget); + } + + // Check state properties for @DelegateToWidget JMethod getState = findInheritedMethod(type, "getState"); JClassType stateType = getState.getReturnType().isClass(); Collection<Property> properties = bundle.getProperties(stateType); - boolean hasDelegateToWidget = false; for (Property property : properties) { DelegateToWidget delegateToWidget = property .getAnnotation(DelegateToWidget.class); if (delegateToWidget != null) { + // Generate meta data required for @DelegateToWidget bundle.setNeedsDelegateToWidget(property); + + // Find the delegate target method String methodName = DelegateToWidget.Helper .getDelegateTarget(property.getName(), delegateToWidget.value()); @@ -60,13 +70,10 @@ public class WidgetInitVisitor extends TypeVisitor { throw new UnableToCompleteException(); } bundle.setNeedsInvoker(widgetType, delegatedSetter); - hasDelegateToWidget = true; - } - } - if (hasDelegateToWidget || needsCreateWidgetSupport) { - bundle.setNeedsReturnType(type, getWidget); - bundle.setNeedsGwtConstructor(widgetType); + // GWT code needs widget type to find the target method + bundle.setNeedsReturnType(type, getWidget); + } } } diff --git a/client/src/com/vaadin/client/metadata/AsyncBundleLoader.java b/client/src/com/vaadin/client/metadata/AsyncBundleLoader.java index 7bbd93c6e3..2073ab7aab 100644 --- a/client/src/com/vaadin/client/metadata/AsyncBundleLoader.java +++ b/client/src/com/vaadin/client/metadata/AsyncBundleLoader.java @@ -53,13 +53,15 @@ public abstract class AsyncBundleLoader { public void load(BundleLoadCallback callback, TypeDataStore store) { assert state == State.NOT_STARTED; state = State.LOADING; - callbacks.add(callback); + addCallback(callback); load(store); } public void addCallback(BundleLoadCallback callback) { assert state == State.LOADING; - callbacks.add(callback); + if (callback != null) { + callbacks.add(callback); + } } public List<BundleLoadCallback> setLoaded() { diff --git a/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java b/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java index 7d6c209ebf..0549547e38 100644 --- a/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java +++ b/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java @@ -47,10 +47,14 @@ public abstract class ConnectorBundleLoader { loader.addCallback(callback); break; case LOADED: - callback.loaded(); + if (callback != null) { + callback.loaded(); + } break; case ERROR: - callback.failed(loader.getError()); + if (callback != null) { + callback.failed(loader.getError()); + } } } diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java index 9fe99610b2..5d0c23e779 100644 --- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java @@ -209,6 +209,9 @@ public class FieldGroup implements Serializable { */ public void setReadOnly(boolean fieldsReadOnly) { readOnly = fieldsReadOnly; + for (Field<?> field : getFields()) { + field.setReadOnly(fieldsReadOnly); + } } /** diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index 32800506a3..5832b144ec 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -2464,9 +2464,11 @@ public abstract class AbstractCommunicationManager implements Serializable { public void handleBrowserDetailsRequest(WrappedRequest request, WrappedResponse response, VaadinSession session) throws IOException { - assert UI.getCurrent() == null; + session.getLock().lock(); try { + assert UI.getCurrent() == null; + CombinedRequest combinedRequest = new CombinedRequest(request); response.setContentType("application/json; charset=UTF-8"); @@ -2495,6 +2497,8 @@ public abstract class AbstractCommunicationManager implements Serializable { } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); + } finally { + session.getLock().unlock(); } } diff --git a/server/src/com/vaadin/server/CombinedRequest.java b/server/src/com/vaadin/server/CombinedRequest.java index 2364527a65..91c5093ece 100644 --- a/server/src/com/vaadin/server/CombinedRequest.java +++ b/server/src/com/vaadin/server/CombinedRequest.java @@ -114,7 +114,12 @@ public class CombinedRequest implements WrappedRequest { @Override public WrappedSession getWrappedSession() { - return secondRequest.getWrappedSession(); + return getWrappedSession(true); + } + + @Override + public WrappedSession getWrappedSession(boolean allowSessionCreation) { + return secondRequest.getWrappedSession(allowSessionCreation); } @Override diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 9372a08e10..fd95852c6a 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -677,7 +677,10 @@ public class VaadinServlet extends HttpServlet implements Constants { * without using the bootstrap page. */ return true; - + } else if (requestType == RequestType.BROWSER_DETAILS) { + // This is the first request if you are embedding by writing the + // embedding code yourself + return true; } else if (requestType == RequestType.OTHER) { /* * I.e URIs that are not application resources or static (theme) diff --git a/server/src/com/vaadin/server/WrappedHttpServletRequest.java b/server/src/com/vaadin/server/WrappedHttpServletRequest.java index 87c6c521af..99e8881ec1 100644 --- a/server/src/com/vaadin/server/WrappedHttpServletRequest.java +++ b/server/src/com/vaadin/server/WrappedHttpServletRequest.java @@ -18,6 +18,7 @@ package com.vaadin.server; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpSession; import com.vaadin.server.VaadinServlet.ServletService; @@ -56,7 +57,17 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper @Override public WrappedSession getWrappedSession() { - return new WrappedHttpSession(getSession()); + return getWrappedSession(true); + } + + @Override + public WrappedSession getWrappedSession(boolean allowSessionCreation) { + HttpSession session = getSession(allowSessionCreation); + if (session != null) { + return new WrappedHttpSession(session); + } else { + return null; + } } /** @@ -111,4 +122,5 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper } return (WrappedHttpServletRequest) request; } + }
\ No newline at end of file diff --git a/server/src/com/vaadin/server/WrappedPortletRequest.java b/server/src/com/vaadin/server/WrappedPortletRequest.java index dd46194a2a..d4670cfd92 100644 --- a/server/src/com/vaadin/server/WrappedPortletRequest.java +++ b/server/src/com/vaadin/server/WrappedPortletRequest.java @@ -23,6 +23,7 @@ import java.util.Map; import javax.portlet.ClientDataRequest; import javax.portlet.PortletRequest; +import javax.portlet.PortletSession; import javax.portlet.ResourceRequest; import com.vaadin.server.VaadinPortlet.PortletService; @@ -114,7 +115,18 @@ public class WrappedPortletRequest implements WrappedRequest { @Override public WrappedSession getWrappedSession() { - return new WrappedPortletSession(request.getPortletSession()); + return getWrappedSession(true); + } + + @Override + public WrappedSession getWrappedSession(boolean allowSessionCreation) { + PortletSession session = request + .getPortletSession(allowSessionCreation); + if (session != null) { + return new WrappedPortletSession(session); + } else { + return null; + } } /** diff --git a/server/src/com/vaadin/server/WrappedRequest.java b/server/src/com/vaadin/server/WrappedRequest.java index 504f21aed4..aeaff2b384 100644 --- a/server/src/com/vaadin/server/WrappedRequest.java +++ b/server/src/com/vaadin/server/WrappedRequest.java @@ -161,7 +161,8 @@ public interface WrappedRequest extends Serializable { public String getRequestPathInfo(); /** - * Gets the session associated with this request. + * Gets the session associated with this request, creating a new if there is + * no session. * * @see WrappedSession * @see HttpServletRequest#getSession() @@ -172,6 +173,23 @@ public interface WrappedRequest extends Serializable { public WrappedSession getWrappedSession(); /** + * Gets the session associated with this request, optionally creating a new + * if there is no session. + * + * @param allowSessionCreation + * <code>true</code> to create a new session for this request if + * necessary; <code>false</code> to return <code>null</code> if + * there's no current session + * + * @see WrappedSession + * @see HttpServletRequest#getSession(boolean) + * @see PortletRequest#getPortletSession(boolean) + * + * @return the wrapped session for this request + */ + public WrappedSession getWrappedSession(boolean allowSessionCreation); + + /** * Returns the MIME type of the body of the request, or null if the type is * not known. * diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 7f0710c813..3ad0cc57fa 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -799,8 +799,8 @@ public abstract class UI extends AbstractComponentContainer implements /** * Remove the given subwindow from this UI. * - * Since Vaadin 6.5, {@link CloseListener}s are called also when explicitly - * removing a window by calling this method. + * Since Vaadin 6.5, {@link Window.CloseListener}s are called also when + * explicitly removing a window by calling this method. * * Since Vaadin 6.5, returns a boolean indicating if the window was removed * or not. |