Author: ehillenius
Date: Mon May 7 08:10:13 2007
New Revision: 535890
URL: http://svn.apache.org/viewvc?view=rev&rev=535890
Log:
WICKET-542
Modified:
incubator/wicket/trunk/jdk-1.4/pom.xml
incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java
incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html
incubator/wicket/trunk/pom.xml
Modified: incubator/wicket/trunk/jdk-1.4/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/pom.xml?view=diff&rev=535890&r1=535889&r2=535890
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/pom.xml (original)
+++ incubator/wicket/trunk/jdk-1.4/pom.xml Mon May 7 08:10:13 2007
@@ -40,6 +40,7 @@
<module>wicket-spring</module>
<module>wicket-quickstart</module>
<module>wicket-datetime</module>
+ <module>wicket-velocity</module>
</modules>
<build>
<plugins>
Modified:
incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java?view=diff&rev=535890&r1=535889&r2=535890
==============================================================================
---
incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
(original)
+++
incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
Mon May 7 08:10:13 2007
@@ -169,13 +169,14 @@
calendarInit.append(":");
calendarInit.append(value);
}
- // TODO handle arrays
if (i.hasNext())
{
calendarInit.append(",");
}
}
variables.put("calendarInit", calendarInit.toString());
+
+ // render initialization script with the variables interpolated
TextTemplateHeaderContributor.forJavaScript(DatePicker.class,
"DatePicker.js",
Model.valueOf(variables)).renderHead(response);
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java?view=diff&rev=535890&r1=535889&r2=535890
==============================================================================
---
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java
(original)
+++
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/template/PackagedTextTemplate.java
Mon May 7 08:10:13 2007
@@ -17,8 +17,12 @@
package org.apache.wicket.util.template;
import java.io.IOException;
+import java.io.Serializable;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.wicket.Application;
+import org.apache.wicket.MetaDataKey;
import org.apache.wicket.util.io.Streams;
import org.apache.wicket.util.lang.Packages;
import org.apache.wicket.util.resource.IResourceStream;
@@ -38,16 +42,66 @@
// TODO cache templates application scoped with a watch
public class PackagedTextTemplate extends TextTemplate
{
- private static final long serialVersionUID = 1L;
+ private static final class CachedTextTemplate implements Serializable
+ {
+ private static final long serialVersionUID = 1L;
+
+ private final String text;
+
+ CachedTextTemplate(String text)
+ {
+ this.text = text;
+ }
+ }
+
+ private static final class CachedTextTemplateKey implements Serializable
+ {
+ private static final long serialVersionUID = 1L;
+
+ private final Class clazz;
+ private final String path;
+
+ CachedTextTemplateKey(Class clazz, String path)
+ {
+ this.clazz = clazz;
+ this.path = path;
+ }
+
+ }
+
+ private static final class TextTemplateCache implements Serializable
+ {
+ private static final long serialVersionUID = 1L;
+
+ private final Map cache = new ConcurrentHashMap();
+
+ CachedTextTemplate get(CachedTextTemplateKey key)
+ {
+ return (CachedTextTemplate)cache.get(key);
+ }
+
+ void put(CachedTextTemplateKey key, CachedTextTemplate value)
+ {
+ cache.put(key, value);
+ }
+ }
/** log. */
private static final Logger log =
LoggerFactory.getLogger(PackagedTextTemplate.class);
+ private static final long serialVersionUID = 1L;
+
/** class loader stream locator. */
private static final IResourceStreamLocator streamLocator = new
ResourceStreamLocator();
+ private static final MetaDataKey TEXT_TEMPLATE_CACHE_KEY = new
MetaDataKey(
+ TextTemplateCache.class)
+ {
+ private static final long serialVersionUID = 1L;
+ };
+
/** contents */
- private StringBuffer buffer = new StringBuffer();
+ private final StringBuffer buffer = new StringBuffer();
/**
* Constructor.
@@ -100,6 +154,11 @@
super(contentType);
String path = Packages.absolutePath(clazz, fileName);
+
+ Application app = Application.get();
+ TextTemplateCache cache =
(TextTemplateCache)app.getMetaData(TEXT_TEMPLATE_CACHE_KEY);
+ // TODO implement cache
+
IResourceStream stream = streamLocator.locate(clazz, path);
if (stream == null)
@@ -141,6 +200,14 @@
}
/**
+ * @see
org.apache.wicket.util.resource.AbstractStringResourceStream#getString()
+ */
+ public String getString()
+ {
+ return buffer.toString();
+ }
+
+ /**
* Interpolate the map of variables with the content and replace the
content
* with the result. Variables are denoted in this string by the syntax
* ${variableName}. The contents will be altered by replacing each
variable
@@ -173,13 +240,5 @@
public final long length()
{
return buffer.length();
- }
-
- /**
- * @see
org.apache.wicket.util.resource.AbstractStringResourceStream#getString()
- */
- public String getString()
- {
- return buffer.toString();
}
}
Modified: incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml?view=diff&rev=535890&r1=535889&r2=535890
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml (original)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml Mon May 7 08:10:13
2007
@@ -59,8 +59,17 @@
<artifactId>wicket-datetime</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-velocity</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.4</version>
</dependency>
<dependency>
<groupId>httpunit</groupId>
Modified:
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml?view=diff&rev=535890&r1=535889&r2=535890
==============================================================================
---
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml
(original)
+++
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml
Mon May 7 08:10:13 2007
@@ -361,6 +361,15 @@
</init-param>
</filter>
+ <filter>
+ <filter-name>VelocityTemplateApplication</filter-name>
+
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
+ <init-param>
+ <param-name>applicationClassName</param-name>
+
<param-value>org.apache.wicket.examples.velocity.VelocityTemplateApplication</param-value>
+ </init-param>
+ </filter>
+
<filter-mapping>
<filter-name>AjaxApplication</filter-name>
<url-pattern>/ajax/*</url-pattern>
@@ -530,6 +539,11 @@
<filter-name>SpringExample</filter-name>
<url-pattern>/spring/*</url-pattern>
</filter-mapping>
+
+ <filter-mapping>
+ <filter-name>VelocityTemplateApplication</filter-name>
+ <url-pattern>/velocity/*</url-pattern>
+ </filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
Modified:
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html?view=diff&rev=535890&r1=535889&r2=535890
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html
(original)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html
Mon May 7 08:10:13 2007
@@ -49,6 +49,7 @@
<tr><td align="right"><a
href="spring">spring</a></td><td> - Demonstrates integration options with the
Spring framework</td></tr>
<tr><td align="right"><a
href="authentication">authentication</a></td><td> - Demonstrates authentication
for pages</td></tr>
<tr><td align="right"><a
href="authorization">authorization</a></td><td> - Demonstrates authorization
for pages and components</td></tr>
+ <tr><td align="right"><a
href="velocity">velocity</a></td><td> - Shows a Velocity panel in
action</td></tr>
</table>
</ul>
</p>
Modified: incubator/wicket/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/pom.xml?view=diff&rev=535890&r1=535889&r2=535890
==============================================================================
--- incubator/wicket/trunk/pom.xml (original)
+++ incubator/wicket/trunk/pom.xml Mon May 7 08:10:13 2007
@@ -59,6 +59,7 @@
<module>jdk-1.4/wicket-datetime</module>
<module>jdk-1.4/wicket-extensions</module>
<module>jdk-1.4/wicket-spring</module>
+ <module>jdk-1.4/wicket-velocity</module>
<module>jdk-1.5/wicket-spring-annot</module>
<module>jdk-1.5/wicket-auth-roles</module>
<module>jdk-1.5/wicket-jmx</module>
@@ -236,6 +237,12 @@
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-datetime</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-velocity</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>