Updated Branches: refs/heads/wicket-1.5.x bd071e2c0 -> 594f7d509
WICKET-4579 PackageTextTemplate misses locale, style and variation Make it possible to specify the style/variation/locale statically at construction time. Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/594f7d50 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/594f7d50 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/594f7d50 Branch: refs/heads/wicket-1.5.x Commit: 594f7d5094e984bd6031c3f04217ca5d3d2470a9 Parents: bd071e2 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Sun Jun 3 08:00:01 2012 +0300 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Sun Jun 3 08:00:01 2012 +0300 ---------------------------------------------------------------------- .../wicket/util/template/PackageTextTemplate.java | 31 ++++++++++++++- 1 files changed, 29 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/594f7d50/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java b/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java index b3fda0c..d56ba82 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java @@ -17,6 +17,7 @@ package org.apache.wicket.util.template; import java.io.IOException; +import java.util.Locale; import java.util.Map; import org.apache.wicket.Application; @@ -100,6 +101,32 @@ public class PackageTextTemplate extends TextTemplate public PackageTextTemplate(final Class<?> clazz, final String fileName, final String contentType, final String encoding) { + this(clazz, fileName, null, null, null, contentType, encoding); + } + + /** + * Constructor. + * + * @param clazz + * the <code>Class</code> to be used for retrieving the classloader for loading the + * <code>PackagedTextTemplate</code> + * @param fileName + * the name of the file, relative to the <code>clazz</code> position + * @param style + * Any resource style, such as a skin style (see {@link org.apache.wicket.Session}) + * @param variation + * The template's variation (of the style) + * @param locale + * The locale of the resource to load + * @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>" + */ + public PackageTextTemplate(final Class<?> clazz, final String fileName, final String style, final String variation, + final Locale locale, final String contentType, final String encoding) + { super(contentType); String path = Packages.absolutePath(clazz, fileName); @@ -109,12 +136,12 @@ public class PackageTextTemplate extends TextTemplate // first try default class loading locator to find the resource IResourceStream stream = app.getResourceSettings() .getResourceStreamLocator() - .locate(clazz, path); + .locate(clazz, path, style, variation, locale, null, false); if (stream == null) { // if the default locator didn't find the resource then fallback - stream = new ResourceStreamLocator().locate(clazz, path); + stream = new ResourceStreamLocator().locate(clazz, path, style, variation, locale, null, false); } if (stream == null)
