You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/02/25 00:27:46 UTC

svn commit: r380861 - in /myfaces/tomahawk/trunk/sandbox: core/src/main/java/org/apache/myfaces/custom/dojo/ core/src/main/tld/ examples/src/main/webapp/dojo/

Author: werpu
Date: Fri Feb 24 15:27:41 2006
New Revision: 380861

URL: http://svn.apache.org/viewcvs?rev=380861&view=rev
Log:
added an expanded flat so that we can load the expanded and compressed dojo versions

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/dojo/debugconsolejsfonly.jsp

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java?rev=380861&r1=380860&r2=380861&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializer.java Fri Feb 24 15:27:41 2006
@@ -31,7 +31,8 @@
     String                     _require              = null;
     String                     _provide              = null;
     Boolean                    _debugConsole         = null;
-
+    Boolean                    _expanded             = null;
+    
     //we handle that specifically to speed things up (we do not want an NxN runtime complexity via enforced
     //reflection in the utils
     boolean                    dojoConfigParamSet    = false;
@@ -84,11 +85,12 @@
         _provide = (String) values[12];
         _debugConsole = (Boolean) values[13];
         _dojoConfig.setDebugAtAllCosts((Boolean) values[14]);
+        _expanded = (Boolean)values[15];
     }
 
     public Object saveState(FacesContext context)
     {
-        Object values[] = new Object[15];
+        Object values[] = new Object[16];
         values[0] = super.saveState(context);
         values[1] = _dojoConfig.getAllowQueryConfig();
         values[2] = _dojoConfig.getBaseScriptUri();
@@ -104,7 +106,7 @@
         values[12] = _provide;
         values[13] = _debugConsole;
         values[14] = _dojoConfig.getDebugAtAllCosts();
-
+        values[15] = _expanded;
         return values;
     }
 
@@ -322,4 +324,18 @@
         _dojoConfig.setDebugAtAllCosts(debugAtAllCosts);
     }
 
+    public Boolean getExpanded() {
+        return _expanded;
+    }
+    
+    public void setExpanded(Boolean expanded) {
+        
+        //we have a logical or over all expanded tags
+        if(expanded != null) {
+            dojoConfigParamSet = true;
+            DojoUtils.setExpanded(FacesContext.getCurrentInstance(), expanded);
+        }
+        _expanded = expanded;
+    }
+    
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java?rev=380861&r1=380860&r2=380861&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoInitializerTag.java Fri Feb 24 15:27:41 2006
@@ -42,6 +42,9 @@
     String _provide              = null;
     String _debugConsole         = null;
     String _debugAtAllCosts      = null;
+    String _development          = null;
+    String _expanded             = null;
+    
     
     public String getComponentType()
     {
@@ -70,6 +73,8 @@
         _provide = null;
         _debugConsole = null;
         _debugAtAllCosts = null;
+        _development = null;
+        _expanded = null;
     }
 
     protected void setProperties(UIComponent component)
@@ -92,6 +97,9 @@
         super.setBooleanProperty(component, "debugConsole", _debugConsole);
         super.setBooleanProperty(component, "debugAtAllCosts", _debugAtAllCosts);
             
+        super.setBooleanProperty(component,"development", _development);
+    
+        super.setBooleanProperty(component, "expanded", _expanded);
     }
 
     public void setAllowQueryConfig(String allowQueryConfig)
@@ -161,5 +169,13 @@
     public void setDebugAtAllCosts(String debugAtAllCosts)
     {
         this._debugAtAllCosts = debugAtAllCosts;
+    }
+
+    public void setDevelopment(String development) {
+        this._development = development;    
+    }
+    
+    public void setExpanded(String expanded) {
+        this._expanded = expanded;
     }
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java?rev=380861&r1=380860&r2=380861&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/dojo/DojoUtils.java Fri Feb 24 15:27:41 2006
@@ -62,12 +62,6 @@
     private static final String DJCONFIG_REQ_KEY                 = "MYFACES_DJCONFIG";
 
     /**
-     * dojo utils flag which can be altered for various states of the dojo lib
-     */
-    public static final boolean DOJO_COMPRESSED                  = false;
-    public static final boolean DOJO_DEBUG                       = false;
-
-    /**
      * Request singleton getter method for the djConfig object
      *
      * @param context
@@ -100,61 +94,67 @@
     public static void mergeExternalDjConfig(FacesContext context, DojoConfig config)
     {
         //we now do the same as beanutils, but for dependency reasons we code it
-            DojoConfig configSingleton = getDjConfigInstance(context);
-            Class dcConfigClass = DojoConfig.class;
-            Method[] djConfigFieldArr = dcConfigClass.getMethods();
-            for (int cnt = 0; cnt < djConfigFieldArr.length; cnt++)
+        DojoConfig configSingleton = getDjConfigInstance(context);
+        Class dcConfigClass = DojoConfig.class;
+        Method[] djConfigFieldArr = dcConfigClass.getMethods();
+        for (int cnt = 0; cnt < djConfigFieldArr.length; cnt++)
+        {
+
+            try
             {
+                Method configPropertyField = djConfigFieldArr[cnt];
+                String methodCore = null;
+                if (!configPropertyField.getName().startsWith("getClass")
+                        && configPropertyField.getName().startsWith("get")
+                        || configPropertyField.getName().startsWith("is"))
+                    methodCore = (configPropertyField.getName().startsWith("get")) ? configPropertyField.getName()
+                            .substring(3) : configPropertyField.getName().substring(2);
 
-                try
+                if (methodCore != null)
                 {
-                    Method configPropertyField = djConfigFieldArr[cnt];
-                    String methodCore = null;
-                    if(!configPropertyField.getName().startsWith("getClass") && configPropertyField.getName().startsWith("get") || configPropertyField.getName().startsWith("is"))
-                        methodCore = (configPropertyField.getName().startsWith("get")) ? configPropertyField.getName().substring(3) : configPropertyField.getName().substring(2);
-
-                    if (methodCore != null) {
-                        Object val = configPropertyField.invoke(config,null);
-                        if(val != null) {
-                            Class [] setterParams = new Class[1];
-                            setterParams[0] = val.getClass();
-                            Method setMethod = dcConfigClass.getMethod("set"+methodCore, setterParams);
-                            if(setMethod != null) {
-                                Object [] setterArgs = new Object[1];
-                                setterArgs[0] = val;
-                                setMethod.invoke(configSingleton, setterArgs);
-                            }
+                    Object val = configPropertyField.invoke(config, null);
+                    if (val != null)
+                    {
+                        Class[] setterParams = new Class[1];
+                        setterParams[0] = val.getClass();
+                        Method setMethod = dcConfigClass.getMethod("set" + methodCore, setterParams);
+                        if (setMethod != null)
+                        {
+                            Object[] setterArgs = new Object[1];
+                            setterArgs[0] = val;
+                            setMethod.invoke(configSingleton, setterArgs);
                         }
                     }
                 }
-                catch (IllegalArgumentException e)
-                {
-                    log.error(e);
-                }
-                catch (SecurityException e)
-                {
-                    log.error(e);
-                }
-                catch (IllegalAccessException e)
-                {
-                    log.error(e);
-                }
-                catch (InvocationTargetException e)
-                {
-                    log.error(e);
-                }
-                catch (NoSuchMethodException e)
-                {
-                    log.error(e);
-                }
             }
+            catch (IllegalArgumentException e)
+            {
+                log.error(e);
+            }
+            catch (SecurityException e)
+            {
+                log.error(e);
+            }
+            catch (IllegalAccessException e)
+            {
+                log.error(e);
+            }
+            catch (InvocationTargetException e)
+            {
+                log.error(e);
+            }
+            catch (NoSuchMethodException e)
+            {
+                log.error(e);
+            }
+        }
 
     }
 
-    public static void addMainInclude(FacesContext context, String javascriptLocation, DojoConfig config)
+    public static void addMainInclude(FacesContext facesContext, String javascriptLocation, DojoConfig config)
     {
 
-        AddResource addResource = AddResourceFactory.getInstance(context);
+        AddResource addResource = AddResourceFactory.getInstance(facesContext);
         /*
          * var djConfig = {
          isDebug: false
@@ -162,19 +162,21 @@
          TODO add a saner handling of collecting all djconfig data
          and then merging it
          */
-        if (!isInlineScriptSet(context, DJCONFIG_INITKEY))
+        if (!isInlineScriptSet(facesContext, DJCONFIG_INITKEY))
         {
-            addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, DJCONFIG_INITKEY);
-            addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, config.toString());
+            addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, DJCONFIG_INITKEY);
+            addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, config.toString());
         }
-        String dojofile = DOJO_COMPRESSED ? DOJO_FILE : DOJO_FILE_UNCOMPRESSED;
+
+        String dojofile = (getExpanded(facesContext) != null && getExpanded(facesContext).booleanValue())  ? DOJO_FILE_UNCOMPRESSED : DOJO_FILE;
         if (javascriptLocation != null)
         {
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + dojofile);
+            addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, javascriptLocation + dojofile);
         }
         else
         {
-            addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, DojoResourceLoader.class, dojofile);
+            addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, DojoResourceLoader.class,
+                    dojofile);
         }
 
     }
@@ -183,18 +185,18 @@
      * adds a dojo require include to our mix
      * of stuff used
      *
-     * @param context
+     * @param facesContext
      * @param required
      */
-    public static void addRequire(FacesContext context, String required)
+    public static void addRequire(FacesContext facesContext, String required)
     {
-        if (isInlineScriptSet(context, DOJO_REQUIRE + required))
+        if (isInlineScriptSet(facesContext, DOJO_REQUIRE + required))
             return;
 
-        AddResource addResource = AddResourceFactory.getInstance(context);
+        AddResource addResource = AddResourceFactory.getInstance(facesContext);
         String requiredBuilder = createDojoRequireString(required);
 
-        addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, requiredBuilder);
+        addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, requiredBuilder);
     }
 
     /**
@@ -238,20 +240,20 @@
 
     /**
      * writes a local require
-     * @param context the local faces context
+     * @param facesContext the local faces context
      * @param component the component which the reuire is for
      * @param required a require dojo style xx.xx.xx
      * @throws IOException
      */
-    public static void addRequire(FacesContext context, UIComponent component, String required) throws IOException
+    public static void addRequire(FacesContext facesContext, UIComponent component, String required) throws IOException
     {
 
-        if (isInlineScriptSet(context, DOJO_REQUIRE + required))
+        if (isInlineScriptSet(facesContext, DOJO_REQUIRE + required))
             return;
 
         String requiredBuilder = createDojoRequireString(required);
 
-        ResponseWriter writer = context.getResponseWriter();
+        ResponseWriter writer = facesContext.getResponseWriter();
         writer.startElement(HTML.SCRIPT_ELEM, component);
         writer.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
         writer.write(requiredBuilder);
@@ -276,14 +278,14 @@
         addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, providedBuilder);
     }
 
-    public static void addProvide(FacesContext context, UIComponent component, String provided) throws IOException
+    public static void addProvide(FacesContext facesContext, UIComponent component, String provided) throws IOException
     {
-        if (isInlineScriptSet(context, DOJO_PROVIDE + provided))
+        if (isInlineScriptSet(facesContext, DOJO_PROVIDE + provided))
             return;
 
         String providedBuilder = createDojoProvideScript(provided);
 
-        ResponseWriter writer = context.getResponseWriter();
+        ResponseWriter writer = facesContext.getResponseWriter();
         writer.startElement(HTML.SCRIPT_ELEM, component);
         writer.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
         writer.write(providedBuilder);
@@ -313,19 +315,19 @@
      * it will not be set by this method (due to the avoidance
      * of unwanted automatisms causing sideefects)
      * 
-     * @param context
+     * @param facesContext
      * @param component
      * @return
      */
-    public static void addDebugConsole(FacesContext context, UIComponent component) throws IOException
+    public static void addDebugConsole(FacesContext facesContext, UIComponent component) throws IOException
     {
         /*check whether we have a debugging flag already set*/
-        if (isInlineScriptSet(context, "/*DOJO DEBUGCONSOLE ON*/"))
+        if (isInlineScriptSet(facesContext, "/*DOJO DEBUGCONSOLE ON*/"))
             return;
-        AddResource addResource = AddResourceFactory.getInstance(context);
-        addResource.addInlineScriptAtPosition(context, AddResource.HEADER_BEGIN, "/*DOJO DEBUGCONSOLE ON*/");
+        AddResource addResource = AddResourceFactory.getInstance(facesContext);
+        addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, "/*DOJO DEBUGCONSOLE ON*/");
 
-        ResponseWriter writer = context.getResponseWriter();
+        ResponseWriter writer = facesContext.getResponseWriter();
         //we for now have to break html until the dynamic creation
         //isses are resolved, so hold on for this messy code now
         //Since this is for debugging purposes only, we can live with it
@@ -355,7 +357,7 @@
     {
         return "dojo.debug(\"" + stmnt + "\");\n";
     }
-                          
+
     /**
      * helper to write out debug statements
      * this is only a convenience method to reduce the
@@ -366,9 +368,37 @@
      * @return
      * @throws IOException
      */
-    public static void writeDebugStatement(ResponseWriter writer, String stmnt) throws IOException {
+    public static void writeDebugStatement(ResponseWriter writer, String stmnt) throws IOException
+    {
         stmnt = createDebugStatement(stmnt);
         writer.write(stmnt);
+    }
+
+    /**
+     * if this flag is set to true somewhere before
+     * the rendering, the expanded version is loaded
+     * otherwise the nonexpanded version is loaded
+     * 
+     * @param facesContext context because we again have a full request singleton here
+     * @param expanded if set to true the expanded version of the dojo scripts are loaded
+     * otherwise the non expanded ones are loaded
+     */
+    public static void setExpanded(FacesContext facesContext, Boolean expanded)
+    {
+        HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
+        request.setAttribute("DOJO_DEVELOPMENT_INCLUDE", expanded);
+    }
+
+    /**
+     * getter for the expanded flat
+     * @param facesContext
+     * @return
+     */
+    public static Boolean getExpanded(FacesContext facesContext)
+    {
+        HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
+        Boolean devStatus = (Boolean) request.getAttribute("DOJO_DEVELOPMENT_INCLUDE");
+        return devStatus;
     }
 
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=380861&r1=380860&r2=380861&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Fri Feb 24 15:27:41 2006
@@ -945,6 +945,12 @@
 			<rtexprvalue>false</rtexprvalue>
 			<type>java.lang.Boolean</type>
 		</attribute>
+		<attribute>
+			<name>expanded</name>
+			<required>false</required>
+			<rtexprvalue>false</rtexprvalue>
+			<type>java.lang.Boolean</type>
+		</attribute>
 		
 		
 		<attribute>

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/dojo/debugconsolejsfonly.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/dojo/debugconsolejsfonly.jsp?rev=380861&r1=380860&r2=380861&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/dojo/debugconsolejsfonly.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/dojo/debugconsolejsfonly.jsp Fri Feb 24 15:27:41 2006
@@ -39,14 +39,18 @@
 				<s:dojoInitializer require="dojo.widget.Editor" debug="true"/>	
 				<s:dojoInitializer require="dojo.widget.DebugConsole" debugAtAllCosts="false"/>	
 				<s:dojoInitializer require="dojo.widget.ResizeHandle" />	
-				<s:dojoInitializer debugConsole="true"/>
+				<s:dojoInitializer debugConsole="true" expanded="true"/>
 					
 				<f:verbatim>
 					<script type="text/javascript" >
 						function generateSomeDebuggingInfo() {
 							for (var x=0; x<10; x++) {
 								dojo.debug(x + ": Here is some debugging info, should be 10 new lines");
+							
 							}
+							dojo.debug("also note the usage of the expanded attribute");
+							dojo.debug("this attribute set to true loads the expanded version");
+							dojo.debug("otherwise the non expanded version is loaded");
 						}
 					</script>
 				</f:verbatim>