July 23, 2003

Here is the much anticipated TilesTool, to use with Velocity Tools and Struts 1.1 :)

I personally use the nested tiles and tile-controllers features, but I haven't tried other features you might be interested in.

Any comments are welcome on the Velocity Developer's List <velocity-dev@jakarta.apache.org>.

Marinó A. Jónsson


{ { { 

package org.apache.velocity.tools.struts;

import java.util.Stack;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletContext;

import java.io.StringWriter;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.Template;

import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.ComponentDefinition;
import org.apache.struts.tiles.AttributeDefinition;
import org.apache.struts.tiles.DirectStringAttribute;
import org.apache.struts.tiles.DefinitionAttribute;
import org.apache.struts.tiles.DefinitionNameAttribute;
import org.apache.struts.tiles.PathAttribute;
import org.apache.struts.tiles.TilesUtil;
import org.apache.struts.tiles.DefinitionsFactoryException;
import org.apache.struts.tiles.Controller;

import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;


/**
{{{ * <p>Title: TilesTool</p> 
 * <p>Description: A tool to use struts-tiles with Velocity</p> 
 * <p>Usage: 
 * 
 * Just call $tiles.name_of_tile_definition from the template to insert 
 * the tile. 
 * 
 * $tiles.getString("name_of_tile_attribute") fetches a named attribute-value 
 * from the current tiles-context. 
 * 
 * @author <a href="mailto:marinoj@centrum.is">Marino A. Jonsson</a> 
 * @version $Revision: 1.1 $ $Date: 2003/07/24 04:59:21 $ 
 */ 

public class TilesTool implements ViewTool {

{{{ protected ViewContext context;

}

{{{ } } }