You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2008/10/30 17:27:09 UTC

svn commit: r709195 - in /tiles/sandbox/trunk/tiles-velocity: ./ src/ src/main/ src/main/java/ src/main/java/com/ src/main/java/com/anydoby/ src/main/java/com/anydoby/tiles2/ src/main/java/com/anydoby/tiles2/spring/ src/main/java/com/anydoby/tiles2/vel...

Author: apetrelli
Date: Thu Oct 30 09:27:08 2008
New Revision: 709195

URL: http://svn.apache.org/viewvc?rev=709195&view=rev
Log:
TILES-170
Velocity plugin code transferred.

Added:
    tiles/sandbox/trunk/tiles-velocity/pom.xml   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/
    tiles/sandbox/trunk/tiles-velocity/src/main/
    tiles/sandbox/trunk/tiles-velocity/src/main/java/
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/TilesConfigurer.java   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/VelocityTiles2View.java   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/Tiles2Tool.java   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityContextFactory.java   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityTiles2RequestContext.java   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/resources/
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/applicationContext.xml   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/config/
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/config/tiles-defs.xml   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/dispatcher-servlet.xml   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/main_template.vm
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/bottom.vm
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/left.vm
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/right.vm
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/web.xml   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/main/webapp/index.jsp   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/site/
    tiles/sandbox/trunk/tiles-velocity/src/site/apt/
    tiles/sandbox/trunk/tiles-velocity/src/site/apt/intro.apt
    tiles/sandbox/trunk/tiles-velocity/src/site/apt/maven.apt
    tiles/sandbox/trunk/tiles-velocity/src/site/apt/spring.apt
    tiles/sandbox/trunk/tiles-velocity/src/site/apt/velocity.apt
    tiles/sandbox/trunk/tiles-velocity/src/site/site.xml   (with props)
    tiles/sandbox/trunk/tiles-velocity/src/test/
    tiles/sandbox/trunk/tiles-velocity/src/test/java/
    tiles/sandbox/trunk/tiles-velocity/src/test/resources/
Modified:
    tiles/sandbox/trunk/tiles-velocity/   (props changed)

Propchange: tiles/sandbox/trunk/tiles-velocity/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct 30 09:27:08 2008
@@ -0,0 +1,2 @@
+.*
+target

Added: tiles/sandbox/trunk/tiles-velocity/pom.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/pom.xml?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/pom.xml (added)
+++ tiles/sandbox/trunk/tiles-velocity/pom.xml Thu Oct 30 09:27:08 2008
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>com.anydoby</groupId>
+  <artifactId>velocity-tiles2</artifactId>
+  <version>0.0.1</version>
+  <description>Velocity Tiles2 Spring MVC integration layer</description>
+  <inceptionYear>2008</inceptionYear>
+  <name>Velocity Tiles2</name>
+  <developers>
+    <developer>
+      <email>anydoby@gmail.com</email>
+      <name>Sergey Zolotaryov</name>
+      <timezone>+2</timezone>
+      <url>http://anydoby.com</url>
+      <roles>
+        <role>developer</role>
+      </roles>
+    </developer>
+  </developers>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-install-plugin</artifactId>
+        <configuration>
+          <createChecksum>true</createChecksum>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-source-plugin</artifactId>
+        <configuration>
+          <attach>true</attach>
+        </configuration>
+        <executions>
+          <execution>
+            <id>attachsources</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.tiles</groupId>
+      <artifactId>tiles-core</artifactId>
+      <version>2.0.5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-webmvc</artifactId>
+      <version>2.5</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.5</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>1.5</version>
+    </dependency> 
+    <dependency>
+      <groupId>velocity-tools</groupId>
+      <artifactId>velocity-tools-generic</artifactId>
+      <version>1.3</version>
+    </dependency>
+    <dependency>
+      <groupId>velocity-tools</groupId>
+      <artifactId>velocity-tools-view</artifactId>
+      <version>1.3</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <scm>
+    <connection>scm:svn:svn://anydoby.com/anydoby/velocity</connection>
+  </scm>
+</project>
\ No newline at end of file

Propchange: tiles/sandbox/trunk/tiles-velocity/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/TilesConfigurer.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/TilesConfigurer.java?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/TilesConfigurer.java (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/TilesConfigurer.java Thu Oct 30 09:27:08 2008
@@ -0,0 +1,266 @@
+package com.anydoby.tiles2.spring;
+
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * Licensed 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.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.context.ChainedTilesContextFactory;
+import org.apache.tiles.definition.DefinitionsFactory;
+import org.apache.tiles.definition.UrlDefinitionsFactory;
+import org.apache.tiles.definition.digester.DigesterDefinitionsReader;
+import org.apache.tiles.factory.TilesContainerFactory;
+import org.apache.tiles.impl.BasicTilesContainer;
+import org.apache.tiles.preparer.BasicPreparerFactory;
+import org.apache.tiles.servlet.context.ServletTilesContextFactory;
+import org.apache.tiles.web.util.ServletContextAdapter;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.context.ServletContextAware;
+import org.springframework.web.servlet.view.tiles2.SimpleSpringPreparerFactory;
+import org.springframework.web.servlet.view.tiles2.SpringBeanPreparerFactory;
+import org.springframework.web.servlet.view.tiles2.TilesView;
+
+import com.anydoby.tiles2.velocity.VelocityContextFactory;
+
+/**
+ * Helper class to configure Tiles2 for the Spring Framework. See <a
+ * href="http://tiles.apache.org">http://tiles.apache.org</a> for more
+ * information about Tiles, which basically is a templating mechanism for
+ * JSP-based web applications.
+ * 
+ * <p>
+ * The TilesConfigurer simply configures a TilesContainer using a set of files
+ * containing definitions, to be accessed by {@link TilesView} instances.
+ * 
+ * <p>
+ * TilesViews can be managed by any
+ * {@link org.springframework.web.servlet.ViewResolver}. For simple
+ * convention-based view resolution, consider using
+ * {@link org.springframework.web.servlet.view.UrlBasedViewResolver} with the
+ * "viewClass" property set to
+ * "org.springframework.web.servlet.view.tiles2.TilesView".
+ * 
+ * <p>
+ * A typical TilesConfigurer bean definition looks as follows:
+ * 
+ * <pre>
+ * &lt;bean id=&quot;tilesConfigurer&quot; class=&quot;org.springframework.web.servlet.view.tiles2.TilesConfigurer&quot;&gt;
+ *   &lt;property name=&quot;definitions&quot;&gt;
+ *     &lt;list&gt;
+ *       &lt;value&gt;/WEB-INF/defs/general.xml&lt;/value&gt;
+ *       &lt;value&gt;/WEB-INF/defs/widgets.xml&lt;/value&gt;
+ *       &lt;value&gt;/WEB-INF/defs/administrator.xml&lt;/value&gt;
+ *       &lt;value&gt;/WEB-INF/defs/customer.xml&lt;/value&gt;
+ *       &lt;value&gt;/WEB-INF/defs/templates.xml&lt;/value&gt;
+ *     &lt;/list&gt;
+ *   &lt;/property&gt;
+ * &lt;/bean&gt;
+ * </pre>
+ * 
+ * The values in the list are the actual files containing the definitions.
+ * 
+ * @author Juergen Hoeller
+ * @since 2.5
+ * @see VelocityTiles2View
+ * @see org.springframework.web.servlet.view.UrlBasedViewResolver
+ */
+public class TilesConfigurer implements ServletContextAware, InitializingBean, DisposableBean {
+
+    /**
+     * Internal implementation of the ServletConfig interface, to be passed to
+     * the wrapped servlet. Delegates to ServletWrappingController fields and
+     * methods to provide init parameters and other environment info.
+     */
+    private class DelegatingServletConfig implements ServletConfig {
+
+        public String getInitParameter(String paramName) {
+            return tilesPropertyMap.get(paramName);
+        }
+
+        public Enumeration getInitParameterNames() {
+            return Collections.enumeration(tilesPropertyMap.keySet());
+        }
+
+        public ServletContext getServletContext() {
+            return servletContext;
+        }
+
+        public String getServletName() {
+            return "TilesConfigurer";
+        }
+    }
+
+    protected final Log logger = LogFactory.getLog(getClass());
+
+    private final Map<String, String> tilesPropertyMap = new HashMap<String, String>();
+
+    private ServletContext servletContext;
+
+    public TilesConfigurer() {
+        this.tilesPropertyMap.put(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM, TilesContainerFactory.class
+                .getName());
+        this.tilesPropertyMap.put(TilesContainerFactory.CONTEXT_FACTORY_INIT_PARAM, ChainedTilesContextFactory.class
+                .getName());
+        this.tilesPropertyMap.put(TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM, UrlDefinitionsFactory.class
+                .getName());
+        this.tilesPropertyMap.put(TilesContainerFactory.PREPARER_FACTORY_INIT_PARAM, BasicPreparerFactory.class
+                .getName());
+        this.tilesPropertyMap.put(ChainedTilesContextFactory.FACTORY_CLASS_NAMES, VelocityContextFactory.class
+                .getName()
+                + "," + ServletTilesContextFactory.class.getName());
+        this.tilesPropertyMap.put(DefinitionsFactory.LOCALE_RESOLVER_IMPL_PROPERTY,
+                org.springframework.web.servlet.view.tiles2.SpringLocaleResolver.class.getName());
+    }
+
+    /**
+     * Creates and exposes a TilesContainer for this web application.
+     * 
+     * @throws TilesException
+     *             in case of setup failure
+     */
+    public void afterPropertiesSet() throws TilesException {
+        TilesContainer container = createTilesContainer(this.servletContext);
+        TilesAccess.setContainer(this.servletContext, container);
+    }
+
+    /**
+     * Create a TilesContainer for this web application.
+     * 
+     * @param context
+     *            this web application's ServletContext
+     * @return the TilesContainer to expose
+     * @throws TilesException
+     *             in case of setup failure
+     */
+    protected TilesContainer createTilesContainer(ServletContext context) throws TilesException {
+        ServletContextAdapter adaptedContext = new ServletContextAdapter(new DelegatingServletConfig());
+        TilesContainerFactory factory = TilesContainerFactory.getFactory(adaptedContext);
+        return factory.createContainer(adaptedContext);
+    }
+
+    /**
+     * Removes the TilesContainer from this web application.
+     * 
+     * @throws TilesException
+     *             in case of cleanup failure
+     */
+    public void destroy() throws TilesException {
+        TilesAccess.setContainer(this.servletContext, null);
+    }
+
+    /**
+     * Set the Tiles definitions, i.e. the list of files containing the
+     * definitions. Default is "/WEB-INF/tiles.xml".
+     */
+    public void setDefinitions(String[] definitions) {
+        if (definitions != null) {
+            String defs = StringUtils.arrayToCommaDelimitedString(definitions);
+            if (logger.isInfoEnabled()) {
+                logger.info("TilesConfigurer: adding definitions [" + defs + "]");
+            }
+            this.tilesPropertyMap.put(BasicTilesContainer.DEFINITIONS_CONFIG, defs);
+        }
+    }
+
+    /**
+     * Set the {@link org.apache.tiles.definition.DefinitionsFactory}
+     * implementation to use. Default is
+     * {@link org.apache.tiles.definition.UrlDefinitionsFactory}, operating on
+     * definition resource URLs.
+     * <p>
+     * Specify a custom DefinitionsFactory, e.g. a UrlDefinitionsFactory
+     * subclass, to customize the creation of Tiles Definition objects. Note
+     * that such a DefinitionsFactory has to be able to handle
+     * {@link java.net.URL} source objects, unless you configure a different
+     * TilesContainerFactory.
+     */
+    public void setDefinitionsFactoryClass(Class definitionsFactoryClass) {
+        this.tilesPropertyMap.put(TilesContainerFactory.DEFINITIONS_FACTORY_INIT_PARAM, definitionsFactoryClass
+                .getName());
+    }
+
+    /**
+     * Set the {@link org.apache.tiles.preparer.PreparerFactory} implementation
+     * to use. Default is {@link org.apache.tiles.preparer.BasicPreparerFactory},
+     * creating shared instances for specified preparer classes.
+     * <p>
+     * Specify {@link SimpleSpringPreparerFactory} to autowire
+     * {@link org.apache.tiles.preparer.ViewPreparer} instances based on
+     * specified preparer classes, applying Spring's container callbacks as well
+     * as applying configured Spring BeanPostProcessors. If Spring's
+     * context-wide annotation-config has been activated, annotations in
+     * ViewPreparer classes will be automatically detected and applied.
+     * <p>
+     * Specify {@link SpringBeanPreparerFactory} to operate on specified
+     * preparer <i>names</i> instead of classes, obtaining the corresponding
+     * Spring bean from the DispatcherServlet's application context. The full
+     * bean creation process will be in the control of the Spring application
+     * context in this case, allowing for the use of scoped beans etc. Note that
+     * you need to define one Spring bean definition per preparer name (as used
+     * in your Tiles definitions).
+     * 
+     * @see SimpleSpringPreparerFactory
+     * @see SpringBeanPreparerFactory
+     */
+    public void setPreparerFactoryClass(Class preparerFactoryClass) {
+        this.tilesPropertyMap.put(TilesContainerFactory.PREPARER_FACTORY_INIT_PARAM, preparerFactoryClass.getName());
+    }
+
+    public void setServletContext(ServletContext servletContext) {
+        this.servletContext = servletContext;
+    }
+
+    /**
+     * Set Tiles properties (equivalent to the ServletContext init-params in the
+     * Tiles documentation), overriding the default settings.
+     */
+    public void setTilesProperties(Properties tilesProperties) {
+        CollectionUtils.mergePropertiesIntoMap(tilesProperties, this.tilesPropertyMap);
+    }
+
+    /**
+     * Set whether to use a MutableTilesContainer for this application. Default
+     * is "false".
+     */
+    public void setUseMutableTilesContainer(boolean useMutableTilesContainer) {
+        this.tilesPropertyMap.put(TilesContainerFactory.CONTAINER_FACTORY_MUTABLE_INIT_PARAM, Boolean
+                .toString(useMutableTilesContainer));
+    }
+
+    /**
+     * Set whether to validate the Tiles XML definitions. Default is "true".
+     */
+    public void setValidateDefinitions(boolean validateDefinitions) {
+        this.tilesPropertyMap.put(DigesterDefinitionsReader.PARSER_VALIDATE_PARAMETER_NAME, Boolean
+                .toString(validateDefinitions));
+    }
+
+}
\ No newline at end of file

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/TilesConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/TilesConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/VelocityTiles2View.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/VelocityTiles2View.java?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/VelocityTiles2View.java (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/VelocityTiles2View.java Thu Oct 30 09:27:08 2008
@@ -0,0 +1,43 @@
+package com.anydoby.tiles2.spring;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.access.TilesAccess;
+import org.apache.velocity.Template;
+import org.apache.velocity.context.Context;
+import org.apache.velocity.tools.view.context.ChainedContext;
+import org.springframework.web.servlet.view.velocity.VelocityToolboxView;
+
+/**
+ * 
+ * @author anydoby
+ * 
+ * @since Mar 16, 2008
+ */
+public class VelocityTiles2View extends VelocityToolboxView {
+
+    private static class TilesTemplate extends Template {
+
+        public TilesTemplate(String definitionName) {
+            setName(definitionName);
+        }
+
+    }
+
+    protected void doRender(Context context, HttpServletResponse response) throws Exception {
+        TilesContainer container = TilesAccess.getContainer(getServletContext());
+        if (context instanceof ChainedContext) {
+            ChainedContext ctx = (ChainedContext) context;
+            container.render(getUrl(), ctx);
+        } else {
+            throw new UnsupportedOperationException("Web context is required");
+        }
+    }
+
+    @Override
+    protected Template getTemplate(final String definitionName) throws Exception {
+        return new TilesTemplate(definitionName);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/VelocityTiles2View.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/spring/VelocityTiles2View.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/Tiles2Tool.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/Tiles2Tool.java?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/Tiles2Tool.java (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/Tiles2Tool.java Thu Oct 30 09:27:08 2008
@@ -0,0 +1,165 @@
+package com.anydoby.tiles2.velocity;
+
+import java.io.IOException;
+
+import org.apache.tiles.Attribute;
+import org.apache.tiles.AttributeContext;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
+import org.apache.velocity.tools.view.context.ChainedContext;
+
+/**
+ * 
+ * @author SergeyZ
+ * 
+ */
+public class Tiles2Tool {
+
+    private final TilesContainer container;
+    private final VelocityTiles2RequestContext context;
+
+    public Tiles2Tool(TilesContainer container, VelocityTiles2RequestContext context) {
+        this.container = container;
+        this.context = context;
+    }
+
+    /**
+     * Returns a string representation of attribute value. If the attribute is
+     * <code>null</code> or if the attribute value is <code>null</code>,
+     * <code>null</code> is returned
+     * 
+     * @param attributeName
+     */
+    public String getAsString(String attributeName) {
+        Attribute attribute = getAttribute(attributeName);
+        String value = null;
+        if (attribute != null) {
+            Object value2 = attribute.getValue();
+            if (value2 != null) {
+                value = value2.toString();
+            }
+        }
+        return value;
+    }
+
+    public Attribute getAttribute(String key) {
+        AttributeContext attributeContext = container.getAttributeContext(context);
+        Attribute attribute = attributeContext.getAttribute(key);
+        return attribute;
+    }
+
+    /**
+     * Imports attribute to current velocity context using the optional toName
+     * as the destination name in context
+     * 
+     * @param attributeName
+     * @param toName
+     */
+    public void importAttribute(String attributeName, String toName) {
+        Object attribute = getAttribute(attributeName);
+        if (toName == null) {
+            toName = attributeName;
+        }
+        context.put(toName, attribute);
+    }
+
+    /**
+     * Invokes {@link #insertAttribute(String, true)}
+     * 
+     * @param attributeName
+     * @throws TilesException
+     * @throws IOException
+     */
+    public void insertAttribute(String attributeName) throws TilesException, IOException {
+        insertAttribute(attributeName, true);
+    }
+
+    /**
+     * <p>
+     * <strong>Inserts the value of an attribute into the page.</strong>
+     * </p>
+     * <p>
+     * This tag can be flexibly used to insert the value of an attribute into a
+     * page. As in other usages in Tiles, every attribute can be determined to
+     * have a "type", either set explicitly when it was defined, or "computed".
+     * If the type is not explicit, then if the attribute value is a valid
+     * definition, it will be inserted as such. Otherwise, if it begins with a
+     * "/" character, it will be treated as a "template". Finally, if it has not
+     * otherwise been assigned a type, it will be treated as a String and
+     * included without any special handling.
+     * </p>
+     * 
+     * @param attributeName
+     * @throws TilesException
+     * @throws IOException
+     */
+    public void insertAttribute(String attributeName, boolean ownContext) throws TilesException, IOException {
+        Attribute attribute = getAttribute(attributeName);
+        if (attribute == null) {
+            throw new TilesException("Attribute '" + attributeName + "' is null");
+        }
+        if (ownContext) {
+            ChainedContext chainedContext = new ChainedContext(context.getContext(), context.getEngine(), context
+                    .getRequest(), context.getResponse(), context.getServletContext());
+            container.startContext(chainedContext);
+            try {
+                render(attribute);
+            } finally {
+                container.endContext(chainedContext);
+            }
+        } else {
+            render(attribute);
+        }
+    }
+
+    /**
+     * Invokes {@link #insertDefinition(String, true)}.
+     * 
+     * @param definitionName
+     * @throws TilesException
+     */
+    public void insertDefinition(String definitionName) throws TilesException {
+        insertDefinition(definitionName, true);
+    }
+
+    /**
+     * Inserts a named definition from the tiles definitions set.
+     * 
+     * @param definitionName
+     * @param ownContext
+     *            if <code>true</code> a separate request context will be
+     *            created for the definition rendering. Can be used to avoid
+     *            name conflicts if the definition being included contains the
+     *            same attribute names as the invoking tile
+     * @throws TilesException
+     */
+    public void insertDefinition(String definitionName, boolean ownContext) throws TilesException {
+        if (ownContext) {
+            ChainedContext chainedContext = new ChainedContext(context.getContext(), context.getEngine(), context
+                    .getRequest(), context.getResponse(), context.getServletContext());
+            container.startContext(chainedContext);
+            try {
+                container.render(definitionName, chainedContext);
+            } finally {
+                container.endContext(chainedContext);
+            }
+        } else {
+            container.render(definitionName, context);
+        }
+    }
+
+    /**
+     * Includes the specified page.
+     * 
+     * @param template
+     * @throws IOException
+     */
+    public void insertTemplate(String template) throws IOException {
+        context.include(template);
+    }
+
+    private void render(Attribute attribute) throws TilesException, IOException {
+        container.render(attribute, context.getResponse().getWriter(), context);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/Tiles2Tool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/Tiles2Tool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityContextFactory.java?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityContextFactory.java (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityContextFactory.java Thu Oct 30 09:27:08 2008
@@ -0,0 +1,48 @@
+package com.anydoby.tiles2.velocity;
+
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.context.TilesContextFactory;
+import org.apache.tiles.context.TilesRequestContext;
+import org.apache.tiles.servlet.context.ServletTilesApplicationContext;
+import org.apache.velocity.context.Context;
+import org.apache.velocity.tools.view.context.ChainedContext;
+
+/**
+ * 
+ * @author anydoby
+ * 
+ * @since Mar 15, 2008
+ */
+public class VelocityContextFactory implements TilesContextFactory {
+
+    public TilesApplicationContext createApplicationContext(Object context) {
+        if (context instanceof ServletContext) {
+            ServletContext servletContext = (ServletContext) context;
+            return new ServletTilesApplicationContext(servletContext);
+        }
+        return null;
+    }
+
+    public TilesRequestContext createRequestContext(TilesApplicationContext context, Object... requestItems) {
+        if (requestItems.length == 1) {
+            if (requestItems[0] instanceof Context) {
+                ChainedContext ctx = (ChainedContext) requestItems[0];
+                return new VelocityTiles2RequestContext(ctx);
+            } else if (requestItems[0] instanceof VelocityTiles2RequestContext) {
+                VelocityTiles2RequestContext ctx = (VelocityTiles2RequestContext) requestItems[0];
+                return ctx;
+            }
+        }
+        return null;
+    }
+
+    public void init(Map<String, String> configurationParameters) {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityContextFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityContextFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityTiles2RequestContext.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityTiles2RequestContext.java?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityTiles2RequestContext.java (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityTiles2RequestContext.java Thu Oct 30 09:27:08 2008
@@ -0,0 +1,54 @@
+package com.anydoby.tiles2.velocity;
+
+import java.io.IOException;
+
+import org.apache.tiles.servlet.context.ServletTilesRequestContext;
+import org.apache.velocity.Template;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.tools.view.context.ChainedContext;
+
+import static org.apache.tiles.access.TilesAccess.getContainer;
+
+/**
+ * 
+ * @author SergeyZ
+ * 
+ */
+public class VelocityTiles2RequestContext extends ServletTilesRequestContext {
+
+    private final ChainedContext ctx;
+
+    public VelocityTiles2RequestContext(ChainedContext ctx) {
+        super(ctx.getServletContext(), ctx.getRequest(), ctx.getResponse());
+        this.ctx = ctx;
+        ctx.put("tiles", new Tiles2Tool(getContainer(ctx.getServletContext()), this));
+    }
+
+    public void dispatch(String path) throws IOException {
+        include(path);
+    }
+
+    public ChainedContext getContext() {
+        return ctx;
+    }
+
+    public VelocityEngine getEngine() {
+        VelocityEngine velocityEngine = ctx.getVelocityEngine();
+        return velocityEngine;
+    }
+
+    @Override
+    public void include(String path) throws IOException {
+        try {
+            Template template = ctx.getVelocityEngine().getTemplate(path);
+            template.merge(ctx, getResponse().getWriter());
+        } catch (Exception e) {
+            throw new IOException(e.getMessage(), e);
+        }
+    }
+
+    public void put(String toName, Object attribute) {
+        ctx.put(toName, attribute);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityTiles2RequestContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/java/com/anydoby/tiles2/velocity/VelocityTiles2RequestContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/applicationContext.xml?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/applicationContext.xml (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/applicationContext.xml Thu Oct 30 09:27:08 2008
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:aop="http://www.springframework.org/schema/aop"
+	xmlns:tx="http://www.springframework.org/schema/tx"
+	xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
+	xmlns:jee="http://www.springframework.org/schema/jee"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
+           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
+           http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd
+           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd"
+	default-dependency-check="none" default-lazy-init="false">
+
+    <bean id="tilesConfigurer" class="com.anydoby.tiles2.spring.TilesConfigurer">
+        <property name="definitions">
+            <list>
+                <value>/WEB-INF/config/tiles-defs.xml</value>
+            </list>
+        </property>
+    </bean>
+
+	<bean id="viewResolver"
+		class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
+		<property name="cache" value="true" />
+		<property name="prefix" value="" />
+		<property name="exposeSpringMacroHelpers" value="true" />
+		<property name="order" value="1"></property>
+		<property name="contentType" value="text/html; charset=utf-8"></property>
+		<property name="suffix" value=".tile" />
+		<property name="viewClass" value="com.anydoby.tiles2.spring.VelocityTiles2View" />
+	</bean>
+
+	<bean id="velocityConfig"
+		class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
+		<property name="resourceLoaderPath"
+			value="/WEB-INF/views,/WEB-INF/macros" />
+		<property name="velocityProperties">
+			<props>
+				<prop key="input.encoding">utf-8</prop>
+				<prop key="output.encoding">utf-8</prop>
+				<!--prop key="toolboxConfigLocation">
+					WEB-INF/config/velocity-toolbox.xml
+				</prop-->
+			</props>
+		</property>
+	</bean>
+
+    <bean id="messageSource"
+        class="org.springframework.context.support.ResourceBundleMessageSource">
+        <property name="basename" value="com.anydoby.jblog.messages" />
+    </bean>
+
+</beans>
\ No newline at end of file

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/applicationContext.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/applicationContext.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/config/tiles-defs.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/config/tiles-defs.xml?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/config/tiles-defs.xml (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/config/tiles-defs.xml Thu Oct 30 09:27:08 2008
@@ -0,0 +1,26 @@
+<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN" "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
+<tiles-definitions>
+  
+  <definition name="main" template="main_template.vm">
+    <put-attribute name="title" value="Title"/>
+    <put-attribute name="right" value="right" type="definition"/>
+  </definition>  
+
+  <definition name="index.tile" extends="main">
+    <put-attribute name="left" value="left" type="definition"/>
+    <put-attribute name="center" value="central part" type="string"/>
+  </definition>
+  
+  <definition name="left" template="tiles/left.vm">
+    <put-attribute name="title" value="left_title"/>
+  </definition>
+  
+  <definition name="right" template="tiles/right.vm">
+    <put-attribute name="title" value="right_title"/>
+  </definition>
+  
+  <definition name="bottom" template="tiles/bottom.vm">
+    <put-attribute name="bottomwords" value="hello bottom"></put-attribute>
+  </definition>
+ 
+</tiles-definitions>

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/config/tiles-defs.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/config/tiles-defs.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/dispatcher-servlet.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/dispatcher-servlet.xml?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/dispatcher-servlet.xml (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/dispatcher-servlet.xml Thu Oct 30 09:27:08 2008
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:aop="http://www.springframework.org/schema/aop"
+	xmlns:tx="http://www.springframework.org/schema/tx"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
+           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
+	default-dependency-check="none"
+	default-lazy-init="false">
+	
+    <bean id="url" class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
+
+    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
+        <property name="defaultHandler" ref="url"></property>
+    </bean>
+  
+
+</beans>
\ No newline at end of file

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/dispatcher-servlet.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/dispatcher-servlet.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/main_template.vm
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/main_template.vm?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/main_template.vm (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/main_template.vm Thu Oct 30 09:27:08 2008
@@ -0,0 +1,25 @@
+<html>
+	<head>
+	   <title>$tiles.getAsString("title")</title>	
+	</head>
+	<body>
+		<table border="1">
+			<tr>
+				<td>
+					$tiles.insertDefinition("left")
+				</td>
+				<td>
+					$tiles.insertAttribute("center")
+				</td>
+				<td>
+					$tiles.insertAttribute("right")
+				</td>
+			</tr>
+			<tr>
+				<td colspan="3">
+					$tiles.insertDefinition("bottom")
+				</td>
+			</tr>
+		</table>
+	</body>
+</html>
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/bottom.vm
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/bottom.vm?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/bottom.vm (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/bottom.vm Thu Oct 30 09:27:08 2008
@@ -0,0 +1 @@
+$tiles.insertAttribute("bottomwords")
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/left.vm
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/left.vm?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/left.vm (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/left.vm Thu Oct 30 09:27:08 2008
@@ -0,0 +1 @@
+$tiles.insertAttribute("title")
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/right.vm
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/right.vm?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/right.vm (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/views/tiles/right.vm Thu Oct 30 09:27:08 2008
@@ -0,0 +1 @@
+$tiles.getAttribute("title")
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/web.xml?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/web.xml (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/web.xml Thu Oct 30 09:27:08 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+    version="2.5">
+
+	<listener>
+		<listener-class>
+			org.springframework.web.context.ContextLoaderListener
+		</listener-class>
+	</listener>
+
+	<servlet>
+		<servlet-name>dispatcher</servlet-name>
+		<servlet-class>
+			org.springframework.web.servlet.DispatcherServlet
+		</servlet-class>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+
+	<servlet-mapping>
+		<servlet-name>dispatcher</servlet-name>
+		<url-pattern>*.htm</url-pattern>
+	</servlet-mapping>
+
+	<welcome-file-list>
+		<welcome-file>/index.jsp</welcome-file>
+	</welcome-file-list>
+
+</web-app>

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/main/webapp/index.jsp?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/main/webapp/index.jsp (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/main/webapp/index.jsp Thu Oct 30 09:27:08 2008
@@ -0,0 +1,4 @@
+<jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page">
+	<jsp:directive.page contentType="text/html; charset=utf-8"/>
+	<jsp:forward page="/index.htm"/>
+</jsp:root>
\ No newline at end of file

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/index.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/main/webapp/index.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-velocity/src/site/apt/intro.apt
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/site/apt/intro.apt?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/site/apt/intro.apt (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/site/apt/intro.apt Thu Oct 30 09:27:08 2008
@@ -0,0 +1,11 @@
+Introduction
+
+  This plugin for Spring MVC will enable you to use Velocity as the rendering technology 
+  along with Tiles2 templating abilities.
+  
+  It provides many of the functions offered by Tiles2 JSP integration layer (which is available
+  in Tiles2 out of the box). Some things like adding an item to the list were not included in the
+  tiles tool, because this task is better performed in the controller, not in the view.
+  
+  You can include the jar file with plugin to your build classpath directly or by using 
+  Maven dependency. For instructions on using the plugin with Maven2, see this page {{maven.html}}.
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-velocity/src/site/apt/maven.apt
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/site/apt/maven.apt?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/site/apt/maven.apt (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/site/apt/maven.apt Thu Oct 30 09:27:08 2008
@@ -0,0 +1,34 @@
+Usage with Maven2
+
+  Here is the sample pom that will get you up and running in no time 
+  
++------------------------------------------+
+<project>
+    ...
+    <dependencies>
+        ...
+        <dependency>
+            <groupId>com.anydoby</groupId>
+            <artifactId>velocity-tiles2</artifactId>
+            <version>0.0.1</version>
+        </dependency>
+        ...
+    </dependencies>
+    ...
+</project>
++------------------------------------------+
+
+  Do not forget to include the repository with plugin into your pom file:
+
++------------------------------------------+
+<project>
+...
+  <repositories>
+    <repository>
+      <id>anydoby.com</id>
+      <url>http://anydoby.com/maven</url>
+    </repository>
+  </repositories>
+...
+</project>
++------------------------------------------+
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-velocity/src/site/apt/spring.apt
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/site/apt/spring.apt?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/site/apt/spring.apt (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/site/apt/spring.apt Thu Oct 30 09:27:08 2008
@@ -0,0 +1,33 @@
+Spring configuration
+
+  The spring configuration is very simple. If you are already using Tiles with velocity you will only
+  have to change the tilesConfigurer bean and the view resolver. Here is the code to do that:
+  
++------------------------------------------+
+...
+	<bean id="tilesConfigurer" class="com.anydoby.tiles2.spring.TilesConfigurer">
+		<property name="definitions">
+			<list>
+				<value>/WEB-INF/config/tiles-defs.xml</value>
+				... place here any number of tiles definition files...
+			</list>
+		</property>
+	</bean>
+...
+	<bean id="viewResolver"
+		class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
+		<property name="cache" value="true" />
+		<property name="prefix" value="" />
+		<property name="exposeSpringMacroHelpers" value="true" />
+		<property name="order" value="1"></property>
+		<property name="contentType" value="text/html; charset=utf-8"></property>
+		<property name="toolboxConfigLocation" value="WEB-INF/config/velocity-toolbox.xml" />
+		<property name="suffix" value=".tile" />
+		<property name="viewClass" value="com.anydoby.tiles2.spring.VelocityTiles2View" />
+	</bean>
+...
++------------------------------------------+
+
+  If you are not using velocity tools you can omit the toolboxConfigLocation. The integration layer
+  project source contains a sample Spring Web MCV project which can be customized for your needs. You
+  can use SVN to download it and build using <<<mvn package>>>. 
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-velocity/src/site/apt/velocity.apt
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/site/apt/velocity.apt?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/site/apt/velocity.apt (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/site/apt/velocity.apt Thu Oct 30 09:27:08 2008
@@ -0,0 +1,53 @@
+Usage from Velocity Templates
+
+  The plugin automatically makes available the Tiles2Tool object under the <<<tiles>>> attribute 
+  for use within Velocity template. Here is the list of commands you can invoke in it:
+  
+  * <<<getAsString(String attributeName)>>> - get the value of named attribute as string.
+  
+  * <<<importAttribute(String attributeName, String toName)>>> - import the named attribute into the scope of 
+  	template context under the (optional) custom name.
+  	
+  * <<<insertAttribute(String attributeName)>>> - inserts given attribute in the output in its own context.
+    If this is a string a string is printed, if this is a definition - it is included in the output.
+    
+  * <<<insertAttribute(String attributeName, boolean ownContext)>>> - inserts given attribute in the output. 
+    If this is a string a string is printed, if this is a definition - it is included in the output. You can specify whether
+    a separate context is created for rendering the definition - in this case variables with duplicate names
+    will not be inherited from the parent definition
+    
+  * <<<insertDefinition(String definitionName)>>> - renders a definition in its own context.
+  
+  * <<<insertDefinition(String definitionName, boolean ownContext)>>> - inserts definition, optionally in the shared context.
+  
+  * <<<insertTemplate(String template)>>> - inserts a named page, equivalent to Velocity's <<<#parse>>>.
+
+  Here is a small example of the page using the tiles tool:
+  
++------------------------------------------+
+<html>
+	<head>
+	   <title>$tiles.getAsString("title")</title>	
+	</head>
+	<body>
+		<table border="1">
+			<tr>
+				<td>
+					$tiles.insertDefinition("left")
+				</td>
+				<td>
+					$tiles.insertAttribute("center")
+				</td>
+				<td>
+					$tiles.insertAttribute("right")
+				</td>
+			</tr>
+			<tr>
+				<td colspan="3">
+					$tiles.insertDefinition("bottom")
+				</td>
+			</tr>
+		</table>
+	</body>
+</html>
++------------------------------------------+
\ No newline at end of file

Added: tiles/sandbox/trunk/tiles-velocity/src/site/site.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-velocity/src/site/site.xml?rev=709195&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-velocity/src/site/site.xml (added)
+++ tiles/sandbox/trunk/tiles-velocity/src/site/site.xml Thu Oct 30 09:27:08 2008
@@ -0,0 +1,14 @@
+<project name="Velocity Tiles2 Spring MVC integration layer">
+   <body>
+      <menu name="Velocity Tiles2 Plugin">
+         <item name="Velocity Tiles2 Plugin home" href="http://anydoby.com/velocity"/>
+      </menu>
+      <menu name="Velocity Tiles2 Plugin Quickstart">
+      	 <item name="Introduction" href="./intro.html"/>
+         <item name="Maven2 Configuration" href="./maven.html"/>
+         <item name="Spring Configuration" href="./spring.html"/>
+         <item name="Usage from Velocity Templates" href="./velocity.html"/>
+      </menu>
+      ${reports}
+   </body>
+</project>
\ No newline at end of file

Propchange: tiles/sandbox/trunk/tiles-velocity/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-velocity/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL