You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by ap...@apache.org on 2010/12/17 16:43:06 UTC
svn commit: r1050428 - in /velocity/tools/trunk: maven-velocity-tools-plugin/
maven-velocity-tools-plugin/src/main/java/org/apache/velocity/tools/plugin/taglib/model/
maven-velocity-tools-plugin/src/main/resources/
maven-velocity-tools-plugin/src/site/...
Author: apetrelli
Date: Fri Dec 17 15:43:05 2010
New Revision: 1050428
URL: http://svn.apache.org/viewvc?rev=1050428&view=rev
Log:
VELTOOLS-133
Added documentation for the plugin.
Refactored velocity-tools-view-jsp a bit.
Added:
velocity/tools/trunk/maven-velocity-tools-plugin/src/site/
velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/
velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/index.apt
velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/usage.apt
velocity/tools/trunk/maven-velocity-tools-plugin/src/site/site.xml
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/
- copied from r1049996, velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/package-info.java
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/package-info.java
Removed:
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/TaglibDirective.java
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/
Modified:
velocity/tools/trunk/maven-velocity-tools-plugin/pom.xml
velocity/tools/trunk/maven-velocity-tools-plugin/src/main/java/org/apache/velocity/tools/plugin/taglib/model/Tag.java
velocity/tools/trunk/maven-velocity-tools-plugin/src/main/resources/jspDirective.vm
velocity/tools/trunk/maven-velocity-tools-plugin/src/test/resources/MySimpleTagDirective.javat
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponse.java
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtils.java
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImpl.java
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContent.java
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragment.java
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContext.java
velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityToolsJspException.java
Modified: velocity/tools/trunk/maven-velocity-tools-plugin/pom.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/maven-velocity-tools-plugin/pom.xml?rev=1050428&r1=1050427&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/maven-velocity-tools-plugin/pom.xml (original)
+++ velocity/tools/trunk/maven-velocity-tools-plugin/pom.xml Fri Dec 17 15:43:05 2010
@@ -1,62 +1,110 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>velocity-tools-parent</artifactId>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>velocity-tools-parent</artifactId>
+ <groupId>org.apache.velocity</groupId>
+ <version>2.1.0-SNAPSHOT</version>
+ </parent>
<groupId>org.apache.velocity</groupId>
+ <artifactId>maven-velocity-tools-plugin</artifactId>
<version>2.1.0-SNAPSHOT</version>
- </parent>
- <groupId>org.apache.velocity</groupId>
- <artifactId>maven-velocity-tools-plugin</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <packaging>maven-plugin</packaging>
- <dependencies>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-tools-view-jsp</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>commons-digester</groupId>
- <artifactId>commons-digester</artifactId>
- <version>2.1</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>3.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <packaging>maven-plugin</packaging>
+ <profiles>
+ <profile>
+ <id>maven3</id>
+ <activation>
+ <file>
+ <!-- This employs that the basedir expression is only
+ recognized by Maven 3.x (see MNG-2363) -->
+ <exists>${basedir}</exists>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.0-beta-3</version>
+ <configuration>
+ <inputEncoding>UTF-8</inputEncoding>
+ <outputEncoding>UTF-8</outputEncoding>
+ <reportPlugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin
+ </artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>2.6</version>
+ </plugin>
+ </reportPlugins>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-tools-view-jsp</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>3.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>2.5.1</version>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
\ No newline at end of file
Modified: velocity/tools/trunk/maven-velocity-tools-plugin/src/main/java/org/apache/velocity/tools/plugin/taglib/model/Tag.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/maven-velocity-tools-plugin/src/main/java/org/apache/velocity/tools/plugin/taglib/model/Tag.java?rev=1050428&r1=1050427&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/maven-velocity-tools-plugin/src/main/java/org/apache/velocity/tools/plugin/taglib/model/Tag.java (original)
+++ velocity/tools/trunk/maven-velocity-tools-plugin/src/main/java/org/apache/velocity/tools/plugin/taglib/model/Tag.java Fri Dec 17 15:43:05 2010
@@ -27,7 +27,7 @@ import javax.servlet.jsp.tagext.SimpleTa
import org.apache.commons.digester.annotations.rules.BeanPropertySetter;
import org.apache.commons.digester.annotations.rules.ObjectCreate;
import org.apache.commons.digester.annotations.rules.SetNext;
-import org.apache.velocity.tools.view.jsp.taglib.jspimpl.VelocityToolsJspException;
+import org.apache.velocity.tools.view.jsp.jspimpl.VelocityToolsJspException;
/**
* It represents a tag in a tag library descriptor.
Modified: velocity/tools/trunk/maven-velocity-tools-plugin/src/main/resources/jspDirective.vm
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/maven-velocity-tools-plugin/src/main/resources/jspDirective.vm?rev=1050428&r1=1050427&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/maven-velocity-tools-plugin/src/main/resources/jspDirective.vm (original)
+++ velocity/tools/trunk/maven-velocity-tools-plugin/src/main/resources/jspDirective.vm Fri Dec 17 15:43:05 2010
@@ -16,8 +16,8 @@ import org.apache.velocity.runtime.direc
import org.apache.velocity.runtime.parser.node.ASTMap;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.tools.view.ViewContext;
-import org.apache.velocity.tools.view.jsp.taglib.jspimpl.JspUtils;
-import org.apache.velocity.tools.view.jsp.taglib.jspimpl.VelocityPageContext;
+import org.apache.velocity.tools.view.jsp.jspimpl.JspUtils;
+import org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext;
public class ${tag.reflectedTagClass.simpleName}Directive extends Directive
{
@@ -52,7 +52,11 @@ public class ${tag.reflectedTagClass.sim
try
{
tag.setPageContext(pageContext);
+#if($tag.simpleTag)
+ tag.setParent(oldParentTag);
+#else
tag.setParent(JspUtils.wrapTag(oldParentTag));
+#end
Object obj;
#foreach($attribute in $tag.attributes)
obj = params.get("${attribute.name}");
Added: velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/index.apt?rev=1050428&view=auto
==============================================================================
--- velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/index.apt (added)
+++ velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/index.apt Fri Dec 17 15:43:05 2010
@@ -0,0 +1,18 @@
+ ------
+ Introduction
+ ------
+
+
+Velocity Tools Maven plugin
+
+ Contains Maven plugins that will be used together with Velocity Tools.
+
+* Goals Overview
+
+ Velocity Tools Maven plugin currently contains one goal.
+
+ * {{{./taglib2directive-mojo.html}maven-velocity-tools-plugin:taglib2directive}} generate Velocity directives from a JSP Tag library.
+
+* Usage
+
+ General instructions on how to use the Plugin Name can be found on the {{{./usage.html}usage page}}.
Added: velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/usage.apt?rev=1050428&view=auto
==============================================================================
--- velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/usage.apt (added)
+++ velocity/tools/trunk/maven-velocity-tools-plugin/src/site/apt/usage.apt Fri Dec 17 15:43:05 2010
@@ -0,0 +1,84 @@
+ ------
+ Usage
+ ------
+
+
+Usage
+
+ The Velocity Tools Maven plugin contains mojos to work together with Velocity Tools.
+
+* Generate Velocity directives from JSP tag libraries.
+
+ JSP tag libraries can be wrapped into Velocity directives to use them into Velocity
+ templates.
+
+ Create a new project and configure the plugin.
+
+-----------------------
+<build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>maven-velocity-tools-plugin</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ <configuration>
+ <packageName>org.apache.velocity.tools.examples.displaytag</packageName>
+ <prefix>display</prefix>
+ <tld>META-INF/displaytag.tld</tld>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>displaytag</groupId>
+ <artifactId>displaytag</artifactId>
+ <version>1.2</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>directive-generation</id>
+ <goals>
+ <goal>taglib2directive</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+</build>
+-----------------------
+
+ In this case we are wrapping DisplayTag. Notice the fact that DisplayTag is
+ configured as a dependency of the plugin itself, because it uses it to reflect
+ some properties from the original tag library.
+
+ Add a dependency to the taglib itself:
+
+-----------------------
+<dependencies>
+ <dependency>
+ <groupId>displaytag</groupId>
+ <artifactId>displaytag</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-tools-view-jsp</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </dependency>
+</dependencies>
+-----------------------
+
+ To use it, in your <<<velocity.properties>>> file, add the list of
+ generated directives this way:
+
+-----------------------
+userdirective=org.apache.velocity.tools.examples.displaytag.CaptionTagDirective,\
+ org.apache.velocity.tools.examples.displaytag.ColumnTagDirective,\
+ org.apache.velocity.tools.examples.displaytag.SetPropertyTagDirective,\
+ org.apache.velocity.tools.examples.displaytag.TableFooterTagDirective,\
+ org.apache.velocity.tools.examples.displaytag.TableTagDirective
+-----------------------
Added: velocity/tools/trunk/maven-velocity-tools-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/maven-velocity-tools-plugin/src/site/site.xml?rev=1050428&view=auto
==============================================================================
--- velocity/tools/trunk/maven-velocity-tools-plugin/src/site/site.xml (added)
+++ velocity/tools/trunk/maven-velocity-tools-plugin/src/site/site.xml Fri Dec 17 15:43:05 2010
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ you under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+
+<project name="Apache Velocity Tools">
+ <publishDate position="bottom" format="yyyy-MM-dd HH:mm:ss" />
+ <bannerLeft>
+ <name>Apache Velocity Project</name>
+ <src>/images/velocity_project_wide.png</src>
+ <href>http://velocity.apache.org/</href>
+ </bannerLeft>
+
+ <bannerRight>
+ <name>Apache Velocity</name>
+ <src>/images/velocitytools.png</src>
+ </bannerRight>
+
+ <skin>
+ <groupId>org.apache.velocity.site</groupId>
+ <artifactId>velocity-site-skin</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </skin>
+
+ <body>
+ <breadcrumbs>
+ <item name="Apache" href="http://www.apache.org/" />
+ <item name="Velocity" href="http://velocity.apache.org/" />
+ <item name="Velocity Tools" />
+ </breadcrumbs>
+
+ <links>
+ <item name="Engine" href="http://velocity.apache.org/engine/devel/" />
+ <item name="Tools" href="http://velocity.apache.org/tools/devel/" />
+ <item name="Anakia" href="http://velocity.apache.org/anakia/devel/" />
+ <item name="Texen" href="http://velocity.apache.org/texen/devel/" />
+ <item name="DocBook" href="http://velocity.apache.org/docbook/" />
+ <item name="DVSL" href="http://velocity.apache.org/dvsl/devel/" />
+ </links>
+
+ <menu name="VelocityTools">
+ <item name="Velocity Tools parent module" href="../index.html" />
+ </menu>
+
+ <menu name="Overview">
+ <item name="Introduction" href="index.html" />
+ <item name="Goals" href="plugin-info.html" />
+ <item name="Usage" href="usage.html" />
+ </menu>
+
+ <menu ref="modules" />
+ <menu ref="reports" />
+
+ </body>
+</project>
Modified: velocity/tools/trunk/maven-velocity-tools-plugin/src/test/resources/MySimpleTagDirective.javat
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/maven-velocity-tools-plugin/src/test/resources/MySimpleTagDirective.javat?rev=1050428&r1=1050427&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/maven-velocity-tools-plugin/src/test/resources/MySimpleTagDirective.javat (original)
+++ velocity/tools/trunk/maven-velocity-tools-plugin/src/test/resources/MySimpleTagDirective.javat Fri Dec 17 15:43:05 2010
@@ -52,7 +52,7 @@ public class MySimpleTagDirective extend
try
{
tag.setPageContext(pageContext);
- tag.setParent(JspUtils.wrapTag(oldParentTag));
+ tag.setParent(oldParentTag);
Object obj;
obj = params.get("stringProperty");
if (obj != null) {
Modified: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponse.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponse.java?rev=1050428&r1=1049996&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponse.java (original)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponse.java Fri Dec 17 15:43:05 2010
@@ -19,7 +19,7 @@
* under the License.
*/
-package org.apache.velocity.tools.view.jsp.taglib.jspimpl;
+package org.apache.velocity.tools.view.jsp.jspimpl;
import java.io.PrintWriter;
Modified: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtils.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtils.java?rev=1050428&r1=1049996&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtils.java (original)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtils.java Fri Dec 17 15:43:05 2010
@@ -1,4 +1,23 @@
-package org.apache.velocity.tools.view.jsp.taglib.jspimpl;
+package org.apache.velocity.tools.view.jsp.jspimpl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
import java.io.IOException;
@@ -16,18 +35,42 @@ import org.apache.velocity.context.Inter
import org.apache.velocity.runtime.parser.node.ASTBlock;
import org.apache.velocity.runtime.parser.node.Node;
+/**
+ * Some utilities to work with JSP.
+ */
public class JspUtils
{
+ /**
+ * The attribute name under which the latest encountered tag is put.
+ */
private final static String LATEST_TAG_ATTRIBUTE_NAME = "org.apache.velocity.tools.view.jsp.taglib.jspimpl.LATEST_TAG";
+ /**
+ * Sets the latest tag encountered.
+ *
+ * @param context The Velocity context.
+ * @param tag The tag.
+ */
public static void setLatestTag(Context context, JspTag tag) {
context.put(LATEST_TAG_ATTRIBUTE_NAME, tag);
}
+ /**
+ * Returns the latest tag encountered.
+ *
+ * @param context The Velocity context.
+ * @return The latest tag.
+ */
public static JspTag getLatestJspTag(Context context) {
return (JspTag) context.get(LATEST_TAG_ATTRIBUTE_NAME);
}
+ /**
+ * If necessary, wraps a {@link SimpleTag} into a {@link Tag}.
+ *
+ * @param tag The tag to (possibly) wrap.
+ * @return The wrapped tag, or the tag passed as parameter if it was not necessary.
+ */
public static Tag wrapTag(JspTag tag) {
if (tag == null) {
return null;
@@ -45,6 +88,16 @@ public class JspUtils
+ tag.getClass().getCanonicalName());
}
+ /**
+ * Executes a {@link SimpleTag}.
+ *
+ * @param context The directive context.
+ * @param node The main node of the directive.
+ * @param pageContext The page context.
+ * @param tag The tag to execute.
+ * @throws JspException If something goes wrong.
+ * @throws IOException If something goes wrong.
+ */
public static void executeSimpleTag(InternalContextAdapter context,
Node node, PageContext pageContext, SimpleTag tag)
throws JspException, IOException
@@ -54,6 +107,16 @@ public class JspUtils
tag.doTag();
}
+ /**
+ * Executes a {@link Tag}.
+ *
+ * @param context The directive context.
+ * @param node The main node of the directive.
+ * @param pageContext The page context.
+ * @param tag The tag to execute.
+ * @throws JspException If something goes wrong.
+ * @throws IOException If something goes wrong.
+ */
public static void executeTag(InternalContextAdapter context, Node node,
PageContext pageContext, Tag tag) throws JspException
{
Modified: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImpl.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImpl.java?rev=1050428&r1=1049996&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImpl.java (original)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImpl.java Fri Dec 17 15:43:05 2010
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.velocity.tools.view.jsp.taglib.jspimpl;
+package org.apache.velocity.tools.view.jsp.jspimpl;
import java.io.IOException;
import java.io.Writer;
Modified: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContent.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContent.java?rev=1050428&r1=1049996&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContent.java (original)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContent.java Fri Dec 17 15:43:05 2010
@@ -1,4 +1,23 @@
-package org.apache.velocity.tools.view.jsp.taglib.jspimpl;
+package org.apache.velocity.tools.view.jsp.jspimpl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
import java.io.IOException;
import java.io.Reader;
@@ -15,13 +34,30 @@ import org.apache.velocity.exception.Par
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.parser.node.ASTBlock;
+/**
+ * Publishes a block inside a Velocity directive as a {@link BodyContent}.
+ *
+ */
public class VelocityBodyContent extends BodyContent
{
+ /**
+ * The block to expose.
+ */
private ASTBlock block;
+ /**
+ * The directive context.
+ */
private InternalContextAdapter context;
+ /**
+ * Constructor.
+ *
+ * @param jspWriter The JSP writer to be used by default.
+ * @param block The block to wrap.
+ * @param context The directive context.
+ */
public VelocityBodyContent(JspWriter jspWriter, ASTBlock block,
InternalContextAdapter context)
{
@@ -47,16 +83,20 @@ public class VelocityBodyContent extends
return stringWriter.toString();
} catch (MethodInvocationException e)
{
- throw new VelocityToolsJspException("Cannot invoke a method while rendering a body", e);
+ throw new VelocityToolsJspException(
+ "Cannot invoke a method while rendering a body", e);
} catch (ResourceNotFoundException e)
{
- throw new VelocityToolsJspException("Cannot find a resource while rendering a body", e);
+ throw new VelocityToolsJspException(
+ "Cannot find a resource while rendering a body", e);
} catch (ParseErrorException e)
{
- throw new VelocityToolsJspException("Cannot parse while rendering a body", e);
+ throw new VelocityToolsJspException(
+ "Cannot parse while rendering a body", e);
} catch (IOException e)
{
- throw new VelocityToolsJspException("I/O exception while rendering a body", e);
+ throw new VelocityToolsJspException(
+ "I/O exception while rendering a body", e);
}
}
Modified: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragment.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragment.java?rev=1050428&r1=1049996&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragment.java (original)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragment.java Fri Dec 17 15:43:05 2010
@@ -1,4 +1,23 @@
-package org.apache.velocity.tools.view.jsp.taglib.jspimpl;
+package org.apache.velocity.tools.view.jsp.jspimpl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
import java.io.IOException;
import java.io.Writer;
@@ -11,15 +30,35 @@ import javax.servlet.jsp.tagext.JspFragm
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.runtime.parser.node.ASTBlock;
+/**
+ * Exposes a directive body block as a {@link JspFragment}, i.e. the body of SimpleTag.
+ *
+ */
public class VelocityJspFragment extends JspFragment
{
+ /**
+ * The JSP page context.
+ */
private PageContext pageContext;
+ /**
+ * The block to wrap.
+ */
private ASTBlock block;
+ /**
+ * The directive context.
+ */
private InternalContextAdapter context;
+ /**
+ * Constructor.
+ *
+ * @param pageContext The page context to use.
+ * @param block The block to wrap.
+ * @param context The directive context.
+ */
public VelocityJspFragment(PageContext pageContext, ASTBlock block,
InternalContextAdapter context)
{
Modified: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContext.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContext.java?rev=1050428&r1=1049996&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContext.java (original)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContext.java Fri Dec 17 15:43:05 2010
@@ -1,4 +1,23 @@
-package org.apache.velocity.tools.view.jsp.taglib.jspimpl;
+package org.apache.velocity.tools.view.jsp.jspimpl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
import java.io.IOException;
import java.io.PrintWriter;
@@ -23,23 +42,51 @@ import javax.servlet.jsp.PageContext;
import org.apache.velocity.context.Context;
import org.apache.velocity.tools.view.ViewContext;
+/**
+ * Exposes a Velocity {@link Context}, a request and a response as a {@link PageContext}.
+ *
+ */
public class VelocityPageContext extends PageContext {
+ /**
+ * The Velocity context.
+ */
private Context velocityContext;
+ /**
+ * The writer to use when writing content.
+ */
private Writer velocityWriter;
+ /**
+ * The view context.
+ */
private ViewContext viewContext;
+ /**
+ * The JSP writer, simulated.
+ */
private JspWriter jspWriter;
+ /**
+ * The HTTP request.
+ */
private HttpServletRequest request;
+ /**
+ * The HTTP response.
+ */
private HttpServletResponse response;
+ /**
+ * Constructor.
+ *
+ * @param velocityContext The Velocity context.
+ * @param velocityWriter The writer to be used when writing content.
+ * @param viewContext The View context.
+ */
public VelocityPageContext(Context velocityContext, Writer velocityWriter, ViewContext viewContext)
{
- super();
this.velocityContext = velocityContext;
this.velocityWriter = velocityWriter;
this.viewContext = viewContext;
Modified: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityToolsJspException.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityToolsJspException.java?rev=1050428&r1=1049996&r2=1050428&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityToolsJspException.java (original)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityToolsJspException.java Fri Dec 17 15:43:05 2010
@@ -1,5 +1,28 @@
-package org.apache.velocity.tools.view.jsp.taglib.jspimpl;
+package org.apache.velocity.tools.view.jsp.jspimpl;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * An exception thrown when something bad happens in JSP support for Velocity.
+ *
+ */
public class VelocityToolsJspException extends RuntimeException
{
@@ -8,20 +31,39 @@ public class VelocityToolsJspException e
*/
private static final long serialVersionUID = 7627800888526325645L;
+ /**
+ * Constructor.
+ */
public VelocityToolsJspException()
{
}
+ /**
+ * Constructor.
+ *
+ * @param message The message of the exception.
+ */
public VelocityToolsJspException(String message)
{
super(message);
}
+ /**
+ * Constructor.
+ *
+ * @param cause The cause.
+ */
public VelocityToolsJspException(Throwable cause)
{
super(cause);
}
+ /**
+ * Constructor.
+ *
+ * @param message The message of the exception.
+ * @param cause The cause.
+ */
public VelocityToolsJspException(String message, Throwable cause)
{
super(message, cause);
Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/package-info.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/package-info.java?rev=1050428&view=auto
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/package-info.java (added)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/package-info.java Fri Dec 17 15:43:05 2010
@@ -0,0 +1,26 @@
+/*
+ * $Id: package-info.java 1044659 2010-12-11 14:16:04Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Contains JSP-simulating classes that allows the use of a Velocity environment
+ * under JSP specific classes, like tags.
+ */
+package org.apache.velocity.tools.view.jsp.jspimpl;
+
Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/package-info.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/package-info.java?rev=1050428&view=auto
==============================================================================
--- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/package-info.java (added)
+++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/package-info.java Fri Dec 17 15:43:05 2010
@@ -0,0 +1,25 @@
+/*
+ * $Id: package-info.java 1044659 2010-12-11 14:16:04Z apetrelli $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * JSP support of Velocity (and vice-versa).
+ */
+package org.apache.velocity.tools.view.jsp;
+