You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2011/01/23 09:15:18 UTC

svn commit: r1062343 - in /wicket/trunk/wicket-velocity: ./ src/main/java/org/apache/wicket/velocity/ src/main/java/org/apache/wicket/velocity/markup/html/ src/test/java/org/apache/wicket/contrib/markup/html/velocity/

Author: jdonnerstag
Date: Sun Jan 23 08:15:17 2011
New Revision: 1062343

URL: http://svn.apache.org/viewvc?rev=1062343&view=rev
Log:
had a quick run through. javadoc mostly. Update velocity from 1.4 to 1.7

Modified:
    wicket/trunk/wicket-velocity/pom.xml
    wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/Initializer.java
    wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java
    wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityJavaScriptContributor.java
    wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java
    wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityPage.java
    wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityWithMarkupParsingPage.java

Modified: wicket/trunk/wicket-velocity/pom.xml
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-velocity/pom.xml?rev=1062343&r1=1062342&r2=1062343&view=diff
==============================================================================
--- wicket/trunk/wicket-velocity/pom.xml (original)
+++ wicket/trunk/wicket-velocity/pom.xml Sun Jan 23 08:15:17 2011
@@ -42,9 +42,9 @@
 			<artifactId>wicket-core</artifactId>
 		</dependency>
 		<dependency>
-			<groupId>velocity</groupId>
+			<groupId>org.apache.velocity</groupId>
 			<artifactId>velocity</artifactId>
-			<version>1.4</version>
+			<version>1.7</version>
 		</dependency>
 	</dependencies>
 </project>

Modified: wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/Initializer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/Initializer.java?rev=1062343&r1=1062342&r2=1062343&view=diff
==============================================================================
--- wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/Initializer.java (original)
+++ wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/Initializer.java Sun Jan 23 08:15:17 2011
@@ -47,9 +47,9 @@ public class Initializer implements IIni
 	private static final Logger log = LoggerFactory.getLogger(Initializer.class);
 
 	/**
-	 * @see org.apache.wicket.IInitializer#init(org.apache.wicket.Application)
+	 * {@inheritDoc}
 	 */
-	public void init(Application application)
+	public void init(final Application application)
 	{
 		Properties props = getVelocityProperties(application);
 
@@ -71,7 +71,7 @@ public class Initializer implements IIni
 		}
 	}
 
-	private Properties getVelocityProperties(Application application)
+	private Properties getVelocityProperties(final Application application)
 	{
 		String velocityPropertiesFile = "velocity.properties";
 
@@ -147,9 +147,10 @@ public class Initializer implements IIni
 		}
 	}
 
-	/** {@inheritDoc} */
-	public void destroy(Application application)
+	/**
+	 * {@inheritDoc}
+	 */
+	public void destroy(final Application application)
 	{
 	}
-
 }

Modified: wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java?rev=1062343&r1=1062342&r2=1062343&view=diff
==============================================================================
--- wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java (original)
+++ wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityContributor.java Sun Jan 23 08:15:17 2011
@@ -52,21 +52,20 @@ public class VelocityContributor extends
 	 * "wicket/contrib/util/resource/foo.vm". Wicket provides a nice utility
 	 * {@link org.apache.wicket.util.lang.Packages} for this.
 	 * 
-	 * 
 	 * @param templateName
 	 * @param model
 	 */
-	public VelocityContributor(String templateName, final IModel<? extends Map<?, ?>> model)
+	public VelocityContributor(final String templateName, final IModel<? extends Map<?, ?>> model)
 	{
 		this.templateName = templateName;
 		this.model = model;
 	}
 
 	/**
-	 * @see org.apache.wicket.behavior.AbstractBehavior#detach(org.apache.wicket.Component)
+	 * {@inheritDoc}
 	 */
 	@Override
-	public void detach(Component c)
+	public void detach(final Component c)
 	{
 		if (model instanceof IDetachable)
 		{
@@ -83,10 +82,10 @@ public class VelocityContributor extends
 	}
 
 	/**
-	 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
+	 * {@inheritDoc}
 	 */
 	@Override
-	public void renderHead(Component component, final IHeaderResponse response)
+	public void renderHead(final Component component, final IHeaderResponse response)
 	{
 		CharSequence s = evaluate();
 		if (null != s)
@@ -99,7 +98,7 @@ public class VelocityContributor extends
 	 * @param encoding
 	 *            The encoding
 	 */
-	public void setEncoding(String encoding)
+	public void setEncoding(final String encoding)
 	{
 		this.encoding = encoding;
 	}
@@ -123,6 +122,7 @@ public class VelocityContributor extends
 		{
 			return null;
 		}
+
 		// create a Velocity context object using the model if set
 		final VelocityContext ctx = new VelocityContext(model.getObject());
 
@@ -150,7 +150,8 @@ public class VelocityContributor extends
 		}
 		catch (Exception e)
 		{
-			throw new WicketRuntimeException(e);
+			throw new WicketRuntimeException("Error while executing velocity script: " +
+				templateName, e);
 		}
 	}
 }

Modified: wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityJavaScriptContributor.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityJavaScriptContributor.java?rev=1062343&r1=1062342&r2=1062343&view=diff
==============================================================================
--- wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityJavaScriptContributor.java (original)
+++ wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/VelocityJavaScriptContributor.java Sun Jan 23 08:15:17 2011
@@ -43,8 +43,8 @@ public class VelocityJavaScriptContribut
 	 * @param model
 	 * @param id
 	 */
-	public VelocityJavaScriptContributor(Class<?> clazz, String templatePath,
-		IModel<? extends Map<?, ?>> model, String id)
+	public VelocityJavaScriptContributor(final Class<?> clazz, final String templatePath,
+		final IModel<? extends Map<?, ?>> model, final String id)
 	{
 		super(Packages.absolutePath(clazz, templatePath), model);
 		this.id = id;
@@ -58,19 +58,18 @@ public class VelocityJavaScriptContribut
 	 * @param model
 	 * @param id
 	 */
-	public VelocityJavaScriptContributor(String templatePath, IModel<? extends Map<?, ?>> model,
-		String id)
+	public VelocityJavaScriptContributor(final String templatePath,
+		final IModel<? extends Map<?, ?>> model, final String id)
 	{
 		super(templatePath, model);
 		this.id = id;
 	}
 
 	/**
-	 * @see org.apache.wicket.velocity.VelocityContributor#renderHead(org.apache.wicket.markup.html.
-	 *      IHeaderResponse)
+	 * {@inheritDoc}
 	 */
 	@Override
-	public void renderHead(Component component, IHeaderResponse response)
+	public void renderHead(final Component component, final IHeaderResponse response)
 	{
 		CharSequence s = evaluate();
 		if (s != null)

Modified: wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java?rev=1062343&r1=1062342&r2=1062343&view=diff
==============================================================================
--- wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java (original)
+++ wicket/trunk/wicket-velocity/src/main/java/org/apache/wicket/velocity/markup/html/VelocityPanel.java Sun Jan 23 08:15:17 2011
@@ -43,7 +43,6 @@ import org.apache.wicket.util.string.Str
  * {@link StringResourceStream} implementation, of which there are a number of convenient
  * implementations in the {@link org.apache.wicket.util} package. The model can be any normal
  * {@link Map}, which will be used to create the {@link VelocityContext}.
- * 
  * <p>
  * <b>Note:</b> Be sure to properly initialize the Velocity engine before using
  * {@link VelocityPanel }.
@@ -68,8 +67,9 @@ public abstract class VelocityPanel exte
 	 *            The template resource
 	 * @return an instance of {@link VelocityPanel}
 	 */
-	public static VelocityPanel forTemplateResource(String id, IModel<? extends Map> model,
-		final IResourceStream templateResource)
+	@SuppressWarnings("rawtypes")
+	public static VelocityPanel forTemplateResource(final String id,
+		final IModel<? extends Map> model, final IResourceStream templateResource)
 	{
 		if (templateResource == null)
 		{
@@ -102,6 +102,7 @@ public abstract class VelocityPanel exte
 	 * @param model
 	 *            Model with variables that can be substituted by Velocity.
 	 */
+	@SuppressWarnings("rawtypes")
 	public VelocityPanel(final String id, final IModel<? extends Map> model)
 	{
 		super(id, model);
@@ -133,20 +134,18 @@ public abstract class VelocityPanel exte
 	 * {@inheritDoc}
 	 */
 	@Override
-	public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
+	public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag)
 	{
 		if (!Strings.isEmpty(stackTraceAsString))
 		{
-			// TODO: only display the velocity error/stacktrace in development
-			// mode?
+			// TODO: only display the velocity error/stacktrace in development mode?
 			replaceComponentTagBody(markupStream, openTag,
 				Strings.toMultilineMarkup(stackTraceAsString));
 		}
 		else if (!parseGeneratedMarkup())
 		{
 			// check that no components have been added in case the generated
-			// markup should not be
-			// parsed
+			// markup should not be parsed
 			if (size() > 0)
 			{
 				throw new WicketRuntimeException(
@@ -214,11 +213,12 @@ public abstract class VelocityPanel exte
 	 *            used to read the template
 	 * @return the result of evaluating the velocity template
 	 */
-	private String evaluateVelocityTemplate(Reader templateReader)
+	private String evaluateVelocityTemplate(final Reader templateReader)
 	{
 		if (evaluatedTemplate == null)
 		{
 			// Get model as a map
+			@SuppressWarnings("rawtypes")
 			final Map map = (Map)getDefaultModelObject();
 
 			// create a Velocity context object using the model if set
@@ -286,8 +286,8 @@ public abstract class VelocityPanel exte
 	/**
 	 * {@inheritDoc}
 	 */
-	public final IResourceStream getMarkupResourceStream(MarkupContainer container,
-		Class<?> containerClass)
+	public final IResourceStream getMarkupResourceStream(final MarkupContainer container,
+		final Class<?> containerClass)
 	{
 		Reader reader = getTemplateReader();
 		if (reader == null)
@@ -306,7 +306,7 @@ public abstract class VelocityPanel exte
 	/**
 	 * {@inheritDoc}
 	 */
-	public final String getCacheKey(MarkupContainer container, Class<?> containerClass)
+	public final String getCacheKey(final MarkupContainer container, final Class<?> containerClass)
 	{
 		// don't cache the evaluated template
 		return null;

Modified: wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityPage.java?rev=1062343&r1=1062342&r2=1062343&view=diff
==============================================================================
--- wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityPage.java (original)
+++ wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityPage.java Sun Jan 23 08:15:17 2011
@@ -40,6 +40,6 @@ public class VelocityPage extends WebPag
 		HashMap<String, String> values = new HashMap<String, String>();
 		values.put("message", TEST_STRING);
 		add(VelocityPanel.forTemplateResource("velocityPanel", new Model<HashMap<String, String>>(
-				values), new UrlResourceStream(this.getClass().getResource("test.html"))));
+			values), new UrlResourceStream(this.getClass().getResource("test.html"))));
 	}
 }

Modified: wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityWithMarkupParsingPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityWithMarkupParsingPage.java?rev=1062343&r1=1062342&r2=1062343&view=diff
==============================================================================
--- wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityWithMarkupParsingPage.java (original)
+++ wicket/trunk/wicket-velocity/src/test/java/org/apache/wicket/contrib/markup/html/velocity/VelocityWithMarkupParsingPage.java Sun Jan 23 08:15:17 2011
@@ -23,7 +23,6 @@ import org.apache.wicket.markup.html.Web
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.util.resource.IResourceStream;
-import org.apache.wicket.util.resource.IStringResourceStream;
 import org.apache.wicket.util.resource.UrlResourceStream;
 import org.apache.wicket.velocity.markup.html.VelocityPanel;
 
@@ -42,7 +41,7 @@ public class VelocityWithMarkupParsingPa
 		HashMap<String, String> values = new HashMap<String, String>();
 		values.put("labelId", "message");
 		VelocityPanel velocityPanel = new VelocityPanel("velocityPanel",
-				new Model<HashMap<String, String>>(values))
+			new Model<HashMap<String, String>>(values))
 		{
 			private static final long serialVersionUID = 1L;
 
@@ -63,7 +62,7 @@ public class VelocityWithMarkupParsingPa
 			private static final long serialVersionUID = 1L;
 
 			@Override
-			protected void onComponentTag(ComponentTag tag)
+			protected void onComponentTag(final ComponentTag tag)
 			{
 				super.onComponentTag(tag);
 				// check whether the markupstream can be located