]> source.dussan.org Git - vaadin-framework.git/commitdiff
refactored app init process (for multiple toolkits in portals/mash-ups), some css...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 11 Apr 2008 08:06:50 +0000 (08:06 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 11 Apr 2008 08:06:50 +0000 (08:06 +0000)
svn changeset:4158/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/public/default/common/common.css
src/com/itmill/toolkit/terminal/gwt/public/default/table/table.css
src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java

index 079f7f2f5688c139a90e8dd9c1fbe5302fac3d8a..f5e3c1e2745371754582c936bf2328c4b2614ce4 100644 (file)
@@ -1,11 +1,3 @@
-#itmill-ajax-window {
-       background: #e9eced;
-       font-family: "Trebuchet MS", geneva, helvetica, arial, tahoma, verdana, sans-serif;
-       color: #464f52;
-       font-size: 13px;
-       line-height: 18px;
-       height: 100%;
-}
 /* body tag created by servlet */
 .i-generated-body {
        background: #e9eced;
        margin:0;
        overflow:auto;
 }
+.i-app {
+       background: #e9eced;
+       font-family: "Trebuchet MS", geneva, helvetica, arial, tahoma, verdana, sans-serif;
+       color: #464f52;
+       font-size: 13px;
+       line-height: 18px;
+       height: 100%;
+}
 
 .i-view {
        height: 100%;
-       width: 100%
+       width: 100%;
        overflow: auto; 
        /* avoid scrollbars with margins in root layout */
        margin-top:-1px;
        border-top:1px solid transparent;
 }
 
-#itmill-ajax-window input, 
-#itmill-ajax-window select, 
-#itmill-ajax-window textarea, 
-#itmill-ajax-window button {
+.i-app input, 
+.i-window input, 
+.i-app select, 
+.i-window select, 
+.i-app textarea, 
+.i-window textarea, 
+.i-app button,
+.i-window button {
        font-family: "Trebuchet MS", geneva, helvetica, arial, tahoma, verdana, sans-serif;
        color: #464f52;
 }
 
-#itmill-ajax-window select {
+.i-app select,
+.i-window select {
        padding: 0;
        margin: 0;
 }
index c427ca02e97e666548385a91776ca9ec9742a403..6ed463c1347b56106c73eec0cefa46a1fb909179 100644 (file)
 }
 .i-off div {\r
        text-indent: 6px;
-       color:
 }
 
 
index b87c12ef7a6c81153809b8afbe07b809ebfcc2fe..5dec2cd0377fe54a37306e75d77463ae51e9bc9f 100644 (file)
@@ -700,12 +700,6 @@ public class ApplicationServlet extends HttpServlet {
         // ApplicationServlet.class.getName()+".writeFragment"
         boolean fragment = (request.getAttribute("javax.portlet.request") != null);
 
-        // Window renders are not cacheable
-        response.setHeader("Cache-Control", "no-cache");
-        response.setHeader("Pragma", "no-cache");
-        response.setDateHeader("Expires", 0);
-
-        response.setContentType("text/html");
         final BufferedWriter page = new BufferedWriter(new OutputStreamWriter(
                 response.getOutputStream()));
         final String pathInfo = request.getPathInfo() == null ? "/" : request
@@ -732,102 +726,83 @@ public class ApplicationServlet extends HttpServlet {
             themeUri = staticFilePath + "/" + THEME_DIRECTORY_PATH + themeName;
         }
 
-        if (fragment) {
-            // someone is including this fragment and might want to know
-            // which app was instantiated
-            // TODO not neccessary
-            request.setAttribute(Application.class.getName(), application);
-
-            page.write("<script language='javascript' src='" + staticFilePath
-                    + "/" + WIDGETSET_DIRECTORY_PATH + widgetset + "/"
-                    + widgetset + ".nocache.js'></script>\n");
-            if (themeName != null) {
-                // Custom theme's stylesheet
-                page.write("<link REL=\"stylesheet\" TYPE=\"text/css\" HREF=\""
-                        + themeUri + "/styles.css\">\n");
-            }
-            // TODO styles & win-name from attribute
-            page.write("<div id=\"itmill-ajax-window\"></div>");
-
-            page
-                    .write("<script type=\"text/javascript\">\n"
-                            + " var itmill = {toolkitConfigurations: {'itmill-ajax-window' :{\n"
-                            + "         appUri:'");
-
-            page.write(appUrl);
-
-            // TODO if (!itmill) etc
-
-            page.write("', pathInfo: '" + pathInfo);
-            page.write("', themeUri: ");
-            page.write(themeUri != null ? "'" + themeUri + "'" : "null");
-            if (testingToolsActive) {
-                page.write(", versionInfo : {toolkitVersion:\"");
-                page.write(VERSION);
-                page.write("\",applicationVersion:\"");
-                page.write(application.getVersion());
-                page.write("\"}");
-            }
-            page.write("\n}}\n");
-
-            page.write("};\n</script>\n");
-
-        } else {
-            page
-                    .write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
-                            + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
-
-            page
-                    .write("<html xmlns=\"http://www.w3.org/1999/xhtml\" style=\"width:100%;"
-                            + "height:100%;border:0;margin:0;\">\n<head>\n"
-                            + "<title>"
-                            + title
-                            + "</title>\n"
-                            + "<script type=\"text/javascript\">\n"
-                            + "        var itmill = {toolkitConfigurations: {'itmill-ajax-window' :{\n"
-                            + "                appUri:'");
-
-            page.write(appUrl);
-
-            // TODO simplify if possible (probably)
-
-            page.write("', pathInfo: '" + pathInfo);
-            page.write("', themeUri: ");
-            page.write(themeUri != null ? "'" + themeUri + "'" : "null");
-            if (testingToolsActive) {
-                page.write(", versionInfo : {toolkitVersion:\"");
-                page.write(VERSION);
-                page.write("\",applicationVersion:\"");
-                page.write(application.getVersion());
-                page.write("\"}");
+        boolean testingApplication = testingToolsActive
+                && request.getParameter("TT") != null;
+
+        if (!fragment) {
+            // Window renders are not cacheable
+            response.setCharacterEncoding("utf-8");
+            response.setHeader("Cache-Control", "no-cache");
+            response.setHeader("Pragma", "no-cache");
+            response.setDateHeader("Expires", 0);
+            response.setContentType("text/html");
+
+            // write html header
+            page.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD "
+                    + "XHTML 1.0 Transitional//EN\" "
+                    + "\"http://www.w3.org/TR/xhtml1/"
+                    + "DTD/xhtml1-transitional.dtd\">\n");
+
+            page.write("<html xmlns=\"http://www.w3.org/1999/xhtml\""
+                    + ">\n<head>\n");
+            page.write("<style type=\"text/css\">"
+                    + "html, body {height:100%;}</style>");
+            page.write("<title>" + title + "</title>");
+
+            if (testingApplication) {
+                writeTestingToolsScripts(page, request);
             }
-            page.write("\n}}\n");
-
-            page.write("};\n</script>\n");
 
-            boolean testingWindow = testingToolsActive
-                    && request.getParameter("TT") != null;
+            page.write("\n</head>\n<body class=\"i-generated-body\">\n");
+        }
 
-            if (testingWindow) {
-                writeTestingToolsScripts(page, request);
-            }
+        String appId = appUrl;
+        appId = appId.replaceAll("/", "");
+
+        page.write("<script type=\"text/javascript\">\n");
+        page.write("//<![CDATA[\n");
+        page.write("if(!itmill) {\n var itmill = "
+                + "{toolkitConfigurations:{}, themesLoaded:{}};\n");
+        page.write("document.write('<iframe id=\"__gwt_historyFrame\" "
+                + "style=\"width:0;height:0;border:0;overflow:"
+                + "hidden\" src=\"javascript:false\"></iframe>');\n");
+        page.write("document.write(\"<script language='javascript' src='"
+                + staticFilePath + "/" + WIDGETSET_DIRECTORY_PATH + widgetset
+                + "/" + widgetset + ".nocache.js'><\\/script>\");\n}\n");
+        if (themeName != null) {
+            // Custom theme's stylesheet, load only once
+            page.write("if(!itmill.themesLoaded['" + themeName + "']) {\n");
+            page.write("var stylesheet = document.createElement('link');\n");
+            page.write("stylesheet.setAttribute('rel', 'stylesheet');\n");
+            page.write("stylesheet.setAttribute('type', 'text/css');\n");
+            page.write("stylesheet.setAttribute('href', '" + themeUri
+                    + "/styles.css');\n");
+            page.write("document.getElementsByTagName(\"head\")"
+                    + "[0].appendChild(stylesheet);\n");
+            page.write("itmill.themesLoaded['" + themeName + "'] = true;\n}\n");
+        }
 
-            page.write("<script language='javascript' src='" + staticFilePath
-                    + "/" + WIDGETSET_DIRECTORY_PATH + widgetset + "/"
-                    + widgetset + ".nocache.js'></script>\n");
+        page.write("itmill.toolkitConfigurations[\"" + appId + "\"] = {");
+        page.write("appUri:'" + appUrl + "', ");
+        page.write("pathInfo: '" + pathInfo + "', ");
+        page.write("themeUri:");
+        page.write(themeUri != null ? "'" + themeUri + "'" : "null");
+        if (testingApplication) {
+            page.write(", versionInfo : {toolkitVersion:\"");
+            page.write(VERSION);
+            page.write("\",applicationVersion:\"");
+            page.write(application.getVersion());
+            page.write("\"}");
+        }
+        page.write("};\n//]]>\n</script>\n");
 
-            if (themeName != null) {
-                // Custom theme's stylesheet
-                page.write("<link REL=\"stylesheet\" TYPE=\"text/css\" HREF=\""
-                        + themeUri + "/styles.css\">\n");
-            }
+        page.write("<div id=\"" + appId + "\" class=\"i-app\"></div>\n");
 
-            page
-                    .write("</head>\n<body class=\"i-generated-body\">\n"
-                            + "        <iframe id=\"__gwt_historyFrame\" style=\"width:0;height:0;border:0;overflow:hidden\" src=\"javascript:false\"></iframe>\n"
-                            + "        <div id=\"itmill-ajax-window\" style=\"position: absolute;top:0;left:0;width:100%;height:100%;border:0;margin:0\"></div>"
-                            + "        </body>\n" + "</html>\n");
+        if (!fragment) {
+            // close html
+            page.write("</body>\n</html>\n");
         }
+
         page.close();
 
     }