You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/05/07 19:20:49 UTC
svn commit: r535934 - in /incubator/wicket/trunk/jdk-1.4/wicket-velocity/src:
main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java
test/java/wicket/contrib/markup/html/velocity/VelocityPage.java
Author: ehillenius
Date: Mon May 7 10:20:47 2007
New Revision: 535934
URL: http://svn.apache.org/viewvc?view=rev&rev=535934
Log:
more tweaks + added a factory method for convenience.
Modified:
incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java
incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/test/java/wicket/contrib/markup/html/velocity/VelocityPage.java
Modified: incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java?view=diff&rev=535934&r1=535933&r2=535934
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java Mon May 7 10:20:47 2007
@@ -59,19 +59,49 @@
public abstract class VelocityPanel extends Panel
{
/**
+ * Convenience factory method to create a {@link VelocityPanel} instance
+ * with a given {@link IStringResourceStream template resource}.
+ *
+ * @param id
+ * Component id
+ * @param model
+ * optional model for variable substituation.
+ * @param templateResource
+ * The template resource
+ * @return
+ */
+ public static VelocityPanel forTemplateResource(String id, IModel model,
+ final IStringResourceStream templateResource)
+ {
+ if (templateResource == null)
+ {
+ throw new IllegalArgumentException(
+ "argument templateResource must be not null");
+ }
+
+ return new VelocityPanel(id, model)
+ {
+ protected IStringResourceStream getTemplateResource()
+ {
+ return templateResource;
+ }
+ };
+ }
+
+ /**
* Construct.
*
- * @param name
- * See Component
+ * @param id
+ * Component id
* @param templateResource
* The velocity template as a string resource
* @param model
* Model with variables that can be substituted by Velocity. Must
* return a {@link Map}.
*/
- public VelocityPanel(final String name, final IModel/* <Map> */model)
+ public VelocityPanel(final String id, final IModel/* <Map> */model)
{
- super(name, model);
+ super(id, model);
}
/**
Modified: incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/test/java/wicket/contrib/markup/html/velocity/VelocityPage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/test/java/wicket/contrib/markup/html/velocity/VelocityPage.java?view=diff&rev=535934&r1=535933&r2=535934
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/test/java/wicket/contrib/markup/html/velocity/VelocityPage.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket-velocity/src/test/java/wicket/contrib/markup/html/velocity/VelocityPage.java Mon May 7 10:20:47 2007
@@ -20,7 +20,6 @@
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.Model;
-import org.apache.wicket.util.resource.IStringResourceStream;
import org.apache.wicket.util.resource.UrlResourceStream;
import org.apache.wicket.velocity.markup.html.VelocityPanel;
@@ -40,12 +39,7 @@
{
HashMap values = new HashMap();
values.put("message", TEST_STRING);
- add(new VelocityPanel("velocityPanel", new Model(values))
- {
- protected IStringResourceStream getTemplateResource()
- {
- return new UrlResourceStream(this.getClass().getResource("test.html"));
- }
- });
+ add(VelocityPanel.forTemplateResource("velocityPanel", new Model(values),
+ new UrlResourceStream(this.getClass().getResource("test.html"))));
}
}