Author: jdonnerstag
Date: Sat Nov 27 16:37:02 2010
New Revision: 1039706

URL: http://svn.apache.org/viewvc?rev=1039706&view=rev
Log:
fixed WICKET-3199 add locale etc to TextTemplatePackageResource
Issue: WICKET-3199

Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/TextTemplateResourceReference.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/TextTemplateResourceReference.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/TextTemplateResourceReference.java?rev=1039706&r1=1039705&r2=1039706&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/TextTemplateResourceReference.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/resource/TextTemplateResourceReference.java
 Sat Nov 27 16:37:02 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket.resource;
 
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.wicket.IClusterable;
@@ -63,10 +64,8 @@ public class TextTemplateResourceReferen
        public TextTemplateResourceReference(final Class<?> scope, final String 
fileName,
                IModel<Map<String, Object>> variablesModel)
        {
-               super(scope, fileName);
-
-               textTemplate = new PackagedTextTemplate(scope, fileName);
-               this.variablesModel = variablesModel;
+               this(scope, fileName, PackagedTextTemplate.DEFAULT_CONTENT_TYPE,
+                       PackagedTextTemplate.DEFAULT_ENCODING, variablesModel);
        }
 
        /**
@@ -86,10 +85,7 @@ public class TextTemplateResourceReferen
        public TextTemplateResourceReference(final Class<?> scope, final String 
fileName,
                final String contentType, IModel<Map<String, Object>> 
variablesModel)
        {
-               super(scope, fileName);
-
-               textTemplate = new PackagedTextTemplate(scope, fileName, 
contentType);
-               this.variablesModel = variablesModel;
+               this(scope, fileName, contentType, 
PackagedTextTemplate.DEFAULT_ENCODING, variablesModel);
        }
 
        /**
@@ -111,7 +107,36 @@ public class TextTemplateResourceReferen
        public TextTemplateResourceReference(final Class<?> scope, final String 
fileName,
                final String contentType, final String encoding, 
IModel<Map<String, Object>> variablesModel)
        {
-               super(scope, fileName);
+               this(scope, fileName, contentType, encoding, variablesModel, 
null, null, null);
+       }
+
+       /**
+        * Construct.
+        * 
+        * @param scope
+        *            the <code>Class</code> to be used for retrieving the 
classloader for loading the
+        *            <code>PackagedTextTemplate</code>
+        * @param fileName
+        *            the file name
+        * @param contentType
+        *            the mime type of this resource, such as 
"<code>image/jpeg</code>" or "
+        *            <code>text/html</code>"
+        * @param encoding
+        *            the file's encoding, for example, "<code>UTF-8</code>"
+        * @param variablesModel
+        *            the template variables as a model
+        * @param locale
+        *            Preferred locale for the resource
+        * @param style
+        *            Preferred style for the resource
+        * @param variation
+        *            Preferred variation for the resource
+        */
+       public TextTemplateResourceReference(final Class<?> scope, final String 
fileName,
+               final String contentType, final String encoding,
+               IModel<Map<String, Object>> variablesModel, Locale locale, 
String style, String variation)
+       {
+               super(scope, fileName, locale, style, variation);
 
                textTemplate = new PackagedTextTemplate(scope, fileName, 
contentType, encoding);
                this.variablesModel = variablesModel;

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java?rev=1039706&r1=1039705&r2=1039706&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java
 Sat Nov 27 16:37:02 2010
@@ -92,6 +92,12 @@ public class PackagedTextTemplate extend
                private static final long serialVersionUID = 1L;
        };
 
+       /** The content type used if not provided in the constructor */
+       public static final String DEFAULT_CONTENT_TYPE = "text";
+
+       /** The encoding used if not provided in the constructor */
+       public static final String DEFAULT_ENCODING = null;
+
        /** contents */
        private final StringBuilder buffer = new StringBuilder();
 
@@ -106,7 +112,7 @@ public class PackagedTextTemplate extend
         */
        public PackagedTextTemplate(final Class<?> clazz, final String fileName)
        {
-               this(clazz, fileName, "text");
+               this(clazz, fileName, DEFAULT_CONTENT_TYPE);
        }
 
        /**
@@ -124,7 +130,7 @@ public class PackagedTextTemplate extend
        public PackagedTextTemplate(final Class<?> clazz, final String fileName,
                final String contentType)
        {
-               this(clazz, fileName, contentType, null);
+               this(clazz, fileName, contentType, DEFAULT_ENCODING);
        }
 
        /**
@@ -152,8 +158,9 @@ public class PackagedTextTemplate extend
                app.getMetaData(TEXT_TEMPLATE_CACHE_KEY);
 
                // first try default class loading locator to find the resource
-               IResourceStream stream = 
app.getResourceSettings().getResourceStreamLocator().locate(clazz,
-                       path);
+               IResourceStream stream = app.getResourceSettings()
+                       .getResourceStreamLocator()
+                       .locate(clazz, path);
 
                if (stream == null)
                {


Reply via email to