You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2007/03/28 04:02:58 UTC

svn commit: r523138 - in /struts/struts2/trunk/plugins/dojo/src: main/java/org/apache/struts2/dojo/components/ main/java/org/apache/struts2/dojo/views/jsp/ui/ main/resources/template/ajax/ test/java/org/apache/struts2/dojo/views/jsp/ui/ test/resources/...

Author: musachy
Date: Tue Mar 27 19:02:55 2007
New Revision: 523138

URL: http://svn.apache.org/viewvc?view=rev&rev=523138
Log:
WW-1861 Add "extraLocales" and "locale" to head tag on Dojo plugin

Modified:
    struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java
    struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java
    struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl
    struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest.java
    struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt

Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java?view=diff&rev=523138&r1=523137&r2=523138
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java (original)
+++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Head.java Tue Mar 27 19:02:55 2007
@@ -73,6 +73,8 @@
     private String debug;
     private String compressed;
     private String baseRelativePath;
+    private String extraLocales;
+    private String locale;
     
     public Head(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
         super(stack, request, response);
@@ -85,12 +87,18 @@
     public void evaluateParams() {
         super.evaluateParams();
         
-        if(this.debug != null)
+        if (this.debug != null)
             addParameter("debug", findValue(this.debug, Boolean.class));
-        if(this.compressed != null)
+        if (this.compressed != null)
             addParameter("compressed", findValue(this.compressed, Boolean.class));
-        if(this.baseRelativePath != null)
+        if (this.baseRelativePath != null)
             addParameter("baseRelativePath", findString(this.baseRelativePath));
+        if (this.extraLocales != null) {
+            String locales = findString(this.extraLocales);
+            addParameter("extraLocales", locales.split(","));
+        }
+        if (this.locale != null)
+            addParameter("locale", findString(this.locale));
     }
 
     @Override
@@ -121,5 +129,15 @@
     @StrutsTagAttribute(description="Context relative path of Dojo distribution folder", defaultValue="/struts/dojo")
     public void setBaseRelativePath(String baseRelativePath) {
         this.baseRelativePath = baseRelativePath;
+    }
+
+    @StrutsTagAttribute(description="Comma separated list of locale names to be loaded by Dojo, locale names must be specified as in RFC3066")
+    public void setExtraLocales(String extraLocales) {
+        this.extraLocales = extraLocales;
+    }
+
+    @StrutsTagAttribute(description="Default locale to be used by Dojo, locale name must be specified as in RFC3066")
+    public void setLocale(String locale) {
+        this.locale = locale;
     }
 }

Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java?view=diff&rev=523138&r1=523137&r2=523138
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java (original)
+++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/HeadTag.java Tue Mar 27 19:02:55 2007
@@ -39,7 +39,9 @@
     private String debug;
     private String compressed;
     private String baseRelativePath;
-
+    private String extraLocales;
+    private String locale;
+    
     public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
         return new Head(stack, req, res);
     }
@@ -51,6 +53,8 @@
         head.setDebug(debug);
         head.setCompressed(compressed);
         head.setBaseRelativePath(baseRelativePath);
+        head.setExtraLocales(extraLocales);
+        head.setLocale(locale);
     }
 
     public void setDebug(String debug) {
@@ -63,5 +67,13 @@
 
     public void setCompressed(String compressed) {
         this.compressed = compressed;
+    }
+
+    public void setExtraLocales(String extraLocales) {
+        this.extraLocales = extraLocales;
+    }
+
+    public void setLocale(String locale) {
+        this.locale = locale;
     }
 }

Modified: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl?view=diff&rev=523138&r1=523137&r2=523138
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl (original)
+++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl Tue Mar 27 19:02:55 2007
@@ -3,7 +3,16 @@
     djConfig = {
         isDebug: ${parameters.debug?default(false)?string},
         bindEncoding: "${parameters.encoding}",
-        debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with the includes
+        <#if parameters.locale?if_exists != "">
+          locale: "${parameters.locale}",
+        </#if>
+        <#if parameters.extraLocales?exists>
+          extraLocale: [
+        	<#list parameters.extraLocales as locale>
+        		"${locale}",
+        	</#list>
+          ]
+        </#if>
     };
 </script>
 

Modified: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest.java?view=diff&rev=523138&r1=523137&r2=523138
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest.java (original)
+++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest.java Tue Mar 27 19:02:55 2007
@@ -36,7 +36,9 @@
         
         tag.setDebug("true");
         tag.setCompressed("false");
+        tag.setExtraLocales("a,b,c");
         tag.setBaseRelativePath("/path");
+        tag.setLocale("es");
         tag.doStartTag();
         tag.doEndTag();
 

Modified: struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt?view=diff&rev=523138&r1=523137&r2=523138
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt (original)
+++ struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt Tue Mar 27 19:02:55 2007
@@ -3,7 +3,12 @@
 	djConfig={
 		isDebug: true,
 		bindEncoding: "ISO-8859-1",
-		debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with the includes
+		locale: "es",
+		extraLocale: [
+			"a",
+			"b",
+			"c",
+		]
 		};
 </script>