]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #2150, client side debug console now cannot be opened unless debug flag is...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 4 Nov 2008 08:30:44 +0000 (08:30 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 4 Nov 2008 08:30:44 +0000 (08:30 +0000)
svn changeset:5804/svn branch:trunk

WebContent/WEB-INF/web.xml
src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java

index 7c4b79017061057a8266ad2e981cf5fcde6a91e1..87d3b3d34a52324a322371cffe7c34004168de02 100644 (file)
@@ -9,7 +9,13 @@
   <description>\r
      IT Mill Toolkit examples\r
   </description>\r
-
+    \r
+  <context-param>\r
+       <param-name>Debug</param-name>\r
+       <param-value>true</param-value>\r
+       <description>IT Mill Toolkit debug mode</description>\r
+  </context-param>\r
+    
   <!-- Permit use of IT Mill Testing Tools for this servlet continer -->
   <context-param>
        <param-name>testingToolsActive</param-name>
index 0c2a295347cab8b79e1a8e8cd24afc24ab9cff6d..29ea8ba05f64bf12f178bdd73688371d70bad40a 100755 (executable)
@@ -248,9 +248,13 @@ public class ApplicationConnection {
 
     private native static boolean isDebugMode()
     /*-{
-     var uri = $wnd.location;
-     var re = /debug[^\/]*$/;
-     return re.test(uri);
+        if($wnd.itmill.debug) {
+            var uri = $wnd.location;
+            var re = /debug[^\/]*$/;
+            return re.test(uri);
+        } else {
+            return false;
+        }
      }-*/;
 
     private native static boolean isQuietDebugMode()
@@ -633,7 +637,7 @@ public class ApplicationConnection {
                 }
 
                 if (html.length() != 0) {
-                    INotification n = new INotification(1000 * 60 * 45); //45min
+                    INotification n = new INotification(1000 * 60 * 45); // 45min
                     n.addEventListener(new NotificationRedirect(url));
                     n.show(html, INotification.CENTERED_TOP,
                             INotification.STYLE_SYSTEM);
index 57afcbd30493b55109fa8f88a07af9810e9de6f6..ac33a259efcf3ebe39a85fb26fa5e7afe6cdbf4b 100644 (file)
@@ -149,7 +149,7 @@ public class ApplicationServlet extends HttpServlet {
 
     private String resourcePath = null;
 
-    private String debugMode = "";
+    private boolean debugMode = false;
 
     // Is this servlet application runner
     boolean isApplicationRunnerServlet = false;
@@ -211,17 +211,11 @@ public class ApplicationServlet extends HttpServlet {
                     .getInitParameter(name));
         }
 
-        // Gets the debug window parameter
-        final String debug = getApplicationOrSystemProperty(PARAMETER_DEBUG, "")
-                .toLowerCase();
-
-        // Enables application specific debug
-        if (!"".equals(debug) && !"true".equals(debug)
-                && !"false".equals(debug)) {
-            throw new ServletException(
-                    "If debug parameter is given for an application, it must be 'true' or 'false'");
+        // check if application is in debug mode
+        if (getApplicationOrSystemProperty(PARAMETER_DEBUG, "false").equals(
+                "true")) {
+            debugMode = true;
         }
-        debugMode = debug;
 
         // Gets Testing Tools parameters if feature is activated
         if (getApplicationOrSystemProperty("testingToolsActive", "false")
@@ -872,6 +866,10 @@ public class ApplicationServlet extends HttpServlet {
                     + "itmill.toolkitConfigurations = {};\n"
                     + "itmill.themesLoaded = {}};\n");
 
+            if (isDebugMode()) {
+                page.write("itmill.debug = true;\n");
+            }
+
             page.write("itmill.toolkitConfigurations[\"" + appId + "\"] = {");
             page.write("appUri:'" + appUrl + "', ");
             page.write("pathInfo: '" + pathInfo + "', ");
@@ -912,6 +910,9 @@ public class ApplicationServlet extends HttpServlet {
                     + "if(!itmill) { var itmill = {}} \n"
                     + "itmill.toolkitConfigurations = {};\n"
                     + "itmill.themesLoaded = {};\n");
+            if (isDebugMode()) {
+                page.write("itmill.debug = true;\n");
+            }
             page
                     .write("document.write('<iframe tabIndex=\"-1\" id=\"__gwt_historyFrame\" "
                             + "style=\"width:0;height:0;border:0;overflow:"
@@ -1542,25 +1543,6 @@ public class ApplicationServlet extends HttpServlet {
         return resourcePath + theme + "/" + resource.getResourceId();
     }
 
-    /**
-     * Checks if web adapter is in debug mode. Extra output is generated to log
-     * when debug mode is enabled.
-     * 
-     * @param parameters
-     * @return <code>true</code> if the web adapter is in debug mode. otherwise
-     *         <code>false</code>.
-     */
-    public boolean isDebugMode(Map parameters) {
-        if (parameters != null) {
-            final Object[] debug = (Object[]) parameters.get("debug");
-            if (debug != null && !"false".equals(debug[0].toString())
-                    && !"false".equals(debugMode)) {
-                return true;
-            }
-        }
-        return "true".equals(debugMode);
-    }
-
     /**
      * Implementation of ParameterHandler.ErrorEvent interface.
      */
@@ -1691,4 +1673,12 @@ public class ApplicationServlet extends HttpServlet {
 
     }
 
+    /**
+     * 
+     * @return true if debug mode parameter is defined as "true" in web.xml
+     */
+    public boolean isDebugMode() {
+        return debugMode;
+    }
+
 }
\ No newline at end of file