Changeset 4527

Show
Ignore:
Timestamp:
05/16/08 12:24:59 (7 months ago)
Author:
matti.tahvonen@…
Message:

fixes #1636 (untested)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java

    r4517 r4527  
    801801        appId = appId.replaceAll("[^a-zA-Z0-9]", ""); 
    802802 
    803         page.write("<script type=\"text/javascript\">\n"); 
    804         page.write("//<![CDATA[\n"); 
    805         page.write("if(!itmill || !itmill.toolkitConfigurations) {\n " 
    806                 + "if(!itmill) { var itmill = {}} \n" 
    807                 + "itmill.toolkitConfigurations = {};\n" 
    808                 + "itmill.themesLoaded = {};\n"); 
    809         page.write("document.write('<iframe id=\"__gwt_historyFrame\" " 
    810                 + "style=\"width:0;height:0;border:0;overflow:" 
    811                 + "hidden\" src=\"javascript:false\"></iframe>');\n"); 
    812         page.write("document.write(\"<script language='javascript' src='" 
    813                 + staticFilePath + "/" + WIDGETSET_DIRECTORY_PATH + widgetset 
    814                 + "/" + widgetset + ".nocache.js'><\\/script>\");\n}\n"); 
    815  
    816         page.write("itmill.toolkitConfigurations[\"" + appId + "\"] = {"); 
    817         page.write("appUri:'" + appUrl + "', "); 
    818         page.write("pathInfo: '" + pathInfo + "', "); 
    819         page.write("themeUri:"); 
    820         page.write(themeUri != null ? "'" + themeUri + "'" : "null"); 
    821         if (testingApplication) { 
    822             page.write(", versionInfo : {toolkitVersion:\""); 
    823             page.write(VERSION); 
    824             page.write("\",applicationVersion:\""); 
    825             page.write(application.getVersion()); 
    826             page.write("\"}"); 
    827         } 
    828         page.write("};\n//]]>\n</script>\n"); 
    829  
    830         if (themeName != null) { 
    831             // Custom theme's stylesheet, load only once, in different script 
    832             // tag to be dominate styles injected by widget 
    833             // set 
     803        if (isGecko17(request)) { 
     804            // special start page for gecko 1.7 versions. Firefox 1.0 is not 
     805            // supported, but the hack is make it possible to use linux and 
     806            // hosted mode browser for debugging. Note that due this hack, 
     807            // debugging gwt code in portals with linux will be problematic if 
     808            // there are multiple toolkit portlets visible at the same time. 
     809            // TODO remove this when hosted mode on linux gets newer gecko 
     810 
     811            page.write("<iframe id=\"__gwt_historyFrame\" " 
     812                    + "style=\"width:0;height:0;border:0;overflow:" 
     813                    + "hidden\" src=\"javascript:false\"></iframe>\n"); 
     814            page.write("<script language='javascript' src='" + staticFilePath 
     815                    + "/" + WIDGETSET_DIRECTORY_PATH + widgetset + "/" 
     816                    + widgetset + ".nocache.js'></script>\n"); 
    834817            page.write("<script type=\"text/javascript\">\n"); 
    835818            page.write("//<![CDATA[\n"); 
    836             page.write("if(!itmill.themesLoaded['" + themeName + "']) {\n"); 
    837             page.write("var stylesheet = document.createElement('link');\n"); 
    838             page.write("stylesheet.setAttribute('rel', 'stylesheet');\n"); 
    839             page.write("stylesheet.setAttribute('type', 'text/css');\n"); 
    840             page.write("stylesheet.setAttribute('href', '" + themeUri 
    841                     + "/styles.css');\n"); 
    842             page 
    843                     .write("document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"); 
    844             page.write("itmill.themesLoaded['" + themeName + "'] = true;\n}\n"); 
    845             page.write("//]]>\n</script>\n"); 
     819            page.write("if(!itmill || !itmill.toolkitConfigurations) {\n " 
     820                    + "if(!itmill) { var itmill = {}} \n" 
     821                    + "itmill.toolkitConfigurations = {};\n" 
     822                    + "itmill.themesLoaded = {}};\n"); 
     823 
     824            page.write("itmill.toolkitConfigurations[\"" + appId + "\"] = {"); 
     825            page.write("appUri:'" + appUrl + "', "); 
     826            page.write("pathInfo: '" + pathInfo + "', "); 
     827            page.write("themeUri:"); 
     828            page.write(themeUri != null ? "'" + themeUri + "'" : "null"); 
     829            if (testingApplication) { 
     830                page.write(", versionInfo : {toolkitVersion:\""); 
     831                page.write(VERSION); 
     832                page.write("\",applicationVersion:\""); 
     833                page.write(application.getVersion()); 
     834                page.write("\"}"); 
     835            } 
     836            page.write("};\n//]]>\n</script>\n"); 
     837 
     838            if (themeName != null) { 
     839                // Custom theme's stylesheet, load only once, in different 
     840                // script 
     841                // tag to be dominate styles injected by widget 
     842                // set 
     843                page.write("<script type=\"text/javascript\">\n"); 
     844                page.write("//<![CDATA[\n"); 
     845                page.write("if(!itmill.themesLoaded['" + themeName + "']) {\n"); 
     846                page 
     847                        .write("var stylesheet = document.createElement('link');\n"); 
     848                page.write("stylesheet.setAttribute('rel', 'stylesheet');\n"); 
     849                page.write("stylesheet.setAttribute('type', 'text/css');\n"); 
     850                page.write("stylesheet.setAttribute('href', '" + themeUri 
     851                        + "/styles.css');\n"); 
     852                page 
     853                        .write("document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"); 
     854                page.write("itmill.themesLoaded['" + themeName 
     855                        + "'] = true;\n}\n"); 
     856                page.write("//]]>\n</script>\n"); 
     857            } 
     858 
     859        } else { 
     860            page.write("<script type=\"text/javascript\">\n"); 
     861            page.write("//<![CDATA[\n"); 
     862            page.write("if(!itmill || !itmill.toolkitConfigurations) {\n " 
     863                    + "if(!itmill) { var itmill = {}} \n" 
     864                    + "itmill.toolkitConfigurations = {};\n" 
     865                    + "itmill.themesLoaded = {};\n"); 
     866            page.write("document.write('<iframe id=\"__gwt_historyFrame\" " 
     867                    + "style=\"width:0;height:0;border:0;overflow:" 
     868                    + "hidden\" src=\"javascript:false\"></iframe>');\n"); 
     869            page.write("document.write(\"<script language='javascript' src='" 
     870                    + staticFilePath + "/" + WIDGETSET_DIRECTORY_PATH 
     871                    + widgetset + "/" + widgetset 
     872                    + ".nocache.js'><\\/script>\");\n}\n"); 
     873 
     874            page.write("itmill.toolkitConfigurations[\"" + appId + "\"] = {"); 
     875            page.write("appUri:'" + appUrl + "', "); 
     876            page.write("pathInfo: '" + pathInfo + "', "); 
     877            page.write("themeUri:"); 
     878            page.write(themeUri != null ? "'" + themeUri + "'" : "null"); 
     879            if (testingApplication) { 
     880                page.write(", versionInfo : {toolkitVersion:\""); 
     881                page.write(VERSION); 
     882                page.write("\",applicationVersion:\""); 
     883                page.write(application.getVersion()); 
     884                page.write("\"}"); 
     885            } 
     886            page.write("};\n//]]>\n</script>\n"); 
     887 
     888            if (themeName != null) { 
     889                // Custom theme's stylesheet, load only once, in different 
     890                // script 
     891                // tag to be dominate styles injected by widget 
     892                // set 
     893                page.write("<script type=\"text/javascript\">\n"); 
     894                page.write("//<![CDATA[\n"); 
     895                page.write("if(!itmill.themesLoaded['" + themeName + "']) {\n"); 
     896                page 
     897                        .write("var stylesheet = document.createElement('link');\n"); 
     898                page.write("stylesheet.setAttribute('rel', 'stylesheet');\n"); 
     899                page.write("stylesheet.setAttribute('type', 'text/css');\n"); 
     900                page.write("stylesheet.setAttribute('href', '" + themeUri 
     901                        + "/styles.css');\n"); 
     902                page 
     903                        .write("document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"); 
     904                page.write("itmill.themesLoaded['" + themeName 
     905                        + "'] = true;\n}\n"); 
     906                page.write("//]]>\n</script>\n"); 
     907            } 
    846908        } 
    847909 
     
    859921        page.close(); 
    860922 
     923    } 
     924 
     925    private boolean isGecko17(HttpServletRequest request) { 
     926        final WebBrowser browser = WebApplicationContext.getApplicationContext( 
     927                request.getSession()).getBrowser(); 
     928        if (browser.getBrowserApplication().indexOf("rv:1.7.") > 0 
     929                && browser.getBrowserApplication().indexOf("Gecko") > 0) { 
     930            return true; 
     931        } 
     932        return false; 
    861933    } 
    862934