summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/terminal
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2008-04-04 13:13:04 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2008-04-04 13:13:04 +0000
commitfbe2591351576c7fb3602616b80a99749f0995eb (patch)
treee174813e3d5258313f4fd0353be57a58b2bc9d83 /src/com/itmill/toolkit/terminal
parent95d4f7757851fcdc1ff4ded1033f254e892eca92 (diff)
downloadvaadin-framework-fbe2591351576c7fb3602616b80a99749f0995eb.tar.gz
vaadin-framework-fbe2591351576c7fb3602616b80a99749f0995eb.zip
initial commit for #704
svn changeset:4127/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/terminal')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ApplicationConfiguration.java74
-rwxr-xr-xsrc/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java49
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java14
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java5
4 files changed, 103 insertions, 39 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConfiguration.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConfiguration.java
new file mode 100644
index 0000000000..e36c3dceb6
--- /dev/null
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConfiguration.java
@@ -0,0 +1,74 @@
+package com.itmill.toolkit.terminal.gwt.client;
+
+import java.util.ArrayList;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+public class ApplicationConfiguration {
+
+ private String id;
+ private String themeUri;
+ private String pathInfo;
+ private String appUri;
+ private JavaScriptObject versionInfo;
+
+ public String getRootPanelId() {
+ return id;
+ }
+
+ public String getApplicationUri() {
+ return appUri;
+ }
+
+ public String getPathInfo() {
+ return pathInfo;
+ }
+
+ public String getThemeUri() {
+ return themeUri;
+ }
+
+ public void setAppId(String appId) {
+ id = appId;
+ }
+
+ private native void loadFromDOM()
+ /*-{
+
+ var id = this.@com.itmill.toolkit.terminal.gwt.client.ApplicationConfiguration::id;
+ if($wnd.itmill.toolkitConfigurations && $wnd.itmill.toolkitConfigurations[id]) {
+ var jsobj = $wnd.itmill.toolkitConfigurations[id];
+ var uri = jsobj.appUri;
+ if(uri[uri.lenght -1] != "/") {
+ uri = uri + "/";
+ }
+ this.@com.itmill.toolkit.terminal.gwt.client.ApplicationConfiguration::appUri = uri;
+ this.@com.itmill.toolkit.terminal.gwt.client.ApplicationConfiguration::pathInfo = jsobj.pathInfo;
+ this.@com.itmill.toolkit.terminal.gwt.client.ApplicationConfiguration::themeUri = jsobj.themeUri;
+ if(jsobj.versionInfo) {
+ this.@com.itmill.toolkit.terminal.gwt.client.ApplicationConfiguration::versionInfo = jsobj.versionInfo;
+ }
+
+ } else {
+ $wnd.alert("Toolkit app failed to initialize: " + this.id);
+ }
+
+ }-*/;
+
+ public native static void loadAppIdListFromDOM(ArrayList list)
+ /*-{
+
+ var j;
+ for(j in $wnd.itmill.toolkitConfigurations) {
+ list.@java.util.Collection::add(Ljava/lang/Object;)(j);
+ }
+ }-*/;
+
+ public static ApplicationConfiguration getConfigFromDOM(String appId) {
+ ApplicationConfiguration conf = new ApplicationConfiguration();
+ conf.setAppId(appId);
+ conf.loadFromDOM();
+ return conf;
+ }
+
+}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
index d6e74fe5b3..6a82ad789f 100755
--- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
@@ -44,8 +44,6 @@ public class ApplicationConnection {
public static final String VAR_FIELD_SEPARATOR = "\u001f";
- private final String appUri;
-
private final HashMap resourcesMap = new HashMap();
private static Console console;
@@ -90,14 +88,14 @@ public class ApplicationConnection {
private int activeRequests = 0;
- public ApplicationConnection(WidgetSet widgetSet) {
+ private String applicationUri;
+
+ private ApplicationConfiguration configuration;
+
+ public ApplicationConnection(WidgetSet widgetSet,
+ ApplicationConfiguration cnf) {
this.widgetSet = widgetSet;
- String tmp = getAppUri();
- if (!tmp.endsWith("/")) {
- appUri = tmp + "/";
- } else {
- appUri = tmp;
- }
+ configuration = cnf;
if (isDebugMode()) {
console = new DebugConsole(this);
@@ -122,7 +120,7 @@ public class ApplicationConnection {
initializeClientHooks();
// TODO remove hard coded id name
- view = new IView("itmill-ajax-window");
+ view = new IView(cnf.getRootPanelId());
makeUidlRequest("repaintAll=1");
applicationRunning = true;
@@ -176,6 +174,8 @@ public class ApplicationConnection {
* <li><code>itmill.forceSync()</code> sends pending variable changes, in
* effect synchronizing the server and client state.</li>
* </ul>
+ *
+ * TODO make this multi-app aware
*/
private native void initializeClientHooks()
/*-{
@@ -196,38 +196,19 @@ public class ApplicationConnection {
return re.test(uri);
}-*/;
- public native String getAppUri()
- /*-{
- var u = $wnd.itmill.appUri;
- if (u.indexOf("/") != 0 && u.indexOf("http") != 0) {
- var b = $wnd.location.href;
- var i = b.length-1;
- while (b.charAt(i) != "/" && i>0) i--;
- b = b.substring(0,i+1);
- u = b + u;
- }
- return u;
- }-*/;
+ public String getAppUri() {
+ return configuration.getApplicationUri();
+ };
public boolean hasActiveRequest() {
return uidlRequest.isPending();
}
- private native String getPathInfo()
- /*-{
- return $wnd.itmill.pathInfo;
- }-*/;
-
- private native String getThemeUri()
- /*-{
- return $wnd.itmill.themeUri;
- }-*/;
-
private void makeUidlRequest(String requestData) {
startRequest();
console.log("Making UIDL Request with params: " + requestData);
- final String uri = appUri + "UIDL" + getPathInfo();
+ final String uri = getAppUri() + "UIDL" + configuration.getPathInfo();
final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri);
rb.setHeader("Content-Type",
"application/x-www-form-urlencoded; charset=utf-8");
@@ -762,7 +743,7 @@ public class ApplicationConnection {
return null;
}
if (toolkitUri.startsWith("theme://")) {
- final String themeUri = getThemeUri();
+ final String themeUri = configuration.getThemeUri();
if (themeUri == null) {
console
.error("Theme not set: ThemeResource will not be found. ("
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java
index 968381d4a0..9c4b4aff5d 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java
@@ -4,6 +4,9 @@
package com.itmill.toolkit.terminal.gwt.client;
+import java.util.ArrayList;
+import java.util.Iterator;
+
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ui.IAccordion;
@@ -50,13 +53,18 @@ import com.itmill.toolkit.terminal.gwt.client.ui.richtextarea.IRichTextArea;
public class DefaultWidgetSet implements WidgetSet {
- protected ApplicationConnection appConn;
-
/**
* This is the entry point method.
*/
public void onModuleLoad() {
- appConn = new ApplicationConnection(this);
+ ArrayList appIds = new ArrayList();
+ ApplicationConfiguration.loadAppIdListFromDOM(appIds);
+ for (Iterator iterator = appIds.iterator(); iterator.hasNext();) {
+ String appId = (String) iterator.next();
+ ApplicationConfiguration appConf = ApplicationConfiguration
+ .getConfigFromDOM(appId);
+ new ApplicationConnection(this, appConf);
+ }
}
public Widget createWidget(UIDL uidl) {
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
index 573c0b43c1..1edd69fc72 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
@@ -666,7 +666,8 @@ public class ApplicationServlet extends HttpServlet {
+ title
+ "</title>\n"
+ "<script type=\"text/javascript\">\n"
- + " var itmill = {\n" + " appUri:'");
+ + " var itmill = {toolkitConfigurations: {'itmill-ajax-window' :{\n"
+ + " appUri:'");
final String[] urls = getAppAndWidgetUrl(request);
final String appUrl = urls[0];
@@ -702,7 +703,7 @@ public class ApplicationServlet extends HttpServlet {
page.write("\"}");
}
- page.write("\n};\n</script>\n");
+ page.write("\n}}};\n</script>\n");
boolean testingWindow = testingToolsActive
&& request.getParameter("TT") != null;