You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by dd...@apache.org on 2006/11/02 03:03:04 UTC
svn commit: r470185 [3/5] - in /struts/sandbox/trunk/tiles:
tiles-api/src/main/java/org/apache/tiles/
tiles-core/src/main/java/org/apache/tiles/
tiles-core/src/main/java/org/apache/tiles/access/
tiles-core/src/main/java/org/apache/tiles/beans/ tiles-co...
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java (from r470183, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/digester/DigesterDefinitionsReader.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/digester/DigesterDefinitionsReader.java&r1=470183&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/digester/DigesterDefinitionsReader.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/digester/DigesterDefinitionsReader.java Wed Nov 1 18:03:00 2006
@@ -16,46 +16,46 @@
* limitations under the License.
*/
-package org.apache.tiles.digester;
+package org.apache.tiles.definition.digester;
+
+import org.apache.commons.digester.Digester;
+import org.apache.tiles.definition.ComponentDefinition;
+import org.apache.tiles.definition.DefinitionsFactoryException;
+import org.apache.tiles.definition.DefinitionsReader;
+import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.digester.Digester;
-import org.apache.tiles.ComponentDefinition;
-import org.apache.tiles.DefinitionsFactoryException;
-import org.apache.tiles.DefinitionsReader;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
/**
- * Reads {@link org.apache.tiles.ComponentDefinition ComponentDefinition} objects
+ * Reads {@link org.apache.tiles.definition.ComponentDefinition ComponentDefinition} objects
* from an XML InputStream using Digester.
- *
- * <p>This <code>DefinitionsReader</code> implementation expects the source to be
+ * <p/>
+ * <p>This <code>DefinitionsReader</code> implementation expects the source to be
* passed as an <code>InputStream</code>. It parses XML data from the source and
* builds a Map of ComponentDefinition objects.</p>
- *
+ * <p/>
* <p>The Digester object can be configured by passing in initialization parameters.
* Currently the only parameter that is supported is the <code>validating</code>
* parameter. This value is set to <code>false</code> by default. To enable DTD
* validation for XML ComponentDefinition files, give the init method a parameter
- * with a key of <code>definitions-parser-validate</code> and a value of
+ * with a key of <code>definitions-parser-validate</code> and a value of
* <code>"true"</code>.
- *
+ * <p/>
* <p>The ComponentDefinition objects are stored internally in a Map. The Map is
* stored as an instance variable rather than a local variable in the <code>read</code>
- * method. This means that instances of this class are <strong>not</strong>
+ * method. This means that instances of this class are <strong>not</strong>
* thread-safe and access by multiple threads must be synchronized.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date$
*/
public class DigesterDefinitionsReader implements DefinitionsReader {
-
- /**
- * Digester validation parameter name.
+
+ /**
+ * Digester validation parameter name.
*/
public static final String PARSER_VALIDATE_PARAMETER_NAME =
"definitions-parser-validate";
@@ -86,13 +86,15 @@
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN",
"/org/apache/tiles/resources/tiles-config_2_0.dtd"
};
-
+
/**
* Indicates whether init method has been called.
*/
private boolean inited = false;
- /** Creates a new instance of DigesterDefinitionsReader */
+ /**
+ * Creates a new instance of DigesterDefinitionsReader
+ */
public DigesterDefinitionsReader() {
digester = new Digester();
digester.setValidating(validating);
@@ -102,7 +104,7 @@
// Register our local copy of the DTDs that we can find
for (int i = 0; i < registrations.length; i += 2) {
URL url = this.getClass().getResource(
- registrations[i+1]);
+ registrations[i + 1]);
if (url != null) {
digester.register(registrations[i], url.toString());
}
@@ -111,71 +113,73 @@
/**
* Reads <code>{@link ComponentDefinition}</code> objects from a source.
- *
+ * <p/>
* Implementations should publish what type of source object is expected.
- *
- * @param source The <code>InputStream</code> source from which definitions
- * will be read.
+ *
+ * @param source The <code>InputStream</code> source from which definitions
+ * will be read.
* @return a Map of <code>ComponentDefinition</code> objects read from
- * the source.
- * @throws DefinitionsFactoryException if the source is invalid or
- * an error occurs when reading definitions.
+ * the source.
+ * @throws org.apache.tiles.definition.DefinitionsFactoryException
+ * if the source is invalid or
+ * an error occurs when reading definitions.
*/
public Map read(Object source) throws DefinitionsFactoryException {
-
+
// Get out if we have not been initialized.
if (!inited) {
throw new DefinitionsFactoryException(
- "Definitions reader has not been initialized.");
+ "Definitions reader has not been initialized.");
}
-
+
// This is an instance variable instead of a local variable because
// we want to be able to call the addDefinition method to populate it.
// But we reset the Map here, which, of course, has threading implications.
definitions = new HashMap();
-
+
if (source == null) {
// Perhaps we should throw an exception here.
return null;
}
-
+
InputStream input = null;
try {
input = (InputStream) source;
} catch (ClassCastException e) {
throw new DefinitionsFactoryException(
- "Invalid source type. Requires java.io.InputStream.", e);
+ "Invalid source type. Requires java.io.InputStream.", e);
}
-
+
try {
// set first object in stack
//digester.clear();
digester.push(this);
// parse
digester.parse(input);
-
+
} catch (SAXException e) {
throw new DefinitionsFactoryException(
- "XML error reading definitions.", e);
+ "XML error reading definitions.", e);
} catch (IOException e) {
throw new DefinitionsFactoryException(
- "I/O Error reading definitions.", e);
+ "I/O Error reading definitions.", e);
}
-
+
return definitions;
}
/**
* Initializes the <code>DefinitionsReader</code> object.
- *
+ * <p/>
* This method must be called before the {@link #read} method is called.
- *
+ *
* @param params A map of properties used to set up the reader.
- * @throws DefinitionsFactoryException if required properties are not
- * passed in or the initialization fails.
+ * @throws org.apache.tiles.definition.DefinitionsFactoryException
+ * if required properties are not
+ * passed in or the initialization fails.
*/
public void init(Map params) throws DefinitionsFactoryException {
-
+
if (params != null) {
String value = (String) params.get(PARSER_VALIDATE_PARAMETER_NAME);
if (value != null) {
@@ -183,66 +187,67 @@
}
}
- initDigesterForTilesDefinitionsSyntax( digester );
+ initDigesterForTilesDefinitionsSyntax(digester);
inited = true;
}
-
-
+
+
/**
* Init digester for Tiles syntax with first element = tiles-definitions
+ *
* @param digester Digester instance to use.
*/
- private void initDigesterForTilesDefinitionsSyntax( Digester digester ) {
+ private void initDigesterForTilesDefinitionsSyntax(Digester digester) {
// Common constants
String PACKAGE_NAME = "org.apache.tiles";
String DEFINITION_TAG = "tiles-definitions/definition";
- String definitionHandlerClass = PACKAGE_NAME + ".ComponentDefinition";
+ String definitionHandlerClass = PACKAGE_NAME + ".definition.ComponentDefinition";
- String PUT_TAG = DEFINITION_TAG + "/put";
- String putAttributeHandlerClass = PACKAGE_NAME + ".ComponentAttribute";
+ String PUT_TAG = DEFINITION_TAG + "/put";
+ String putAttributeHandlerClass = PACKAGE_NAME + ".definition.ComponentAttribute";
//String LIST_TAG = DEFINITION_TAG + "/putList";
// List tag value
String LIST_TAG = "putList";
String DEF_LIST_TAG = DEFINITION_TAG + "/" + LIST_TAG;
-
- String listHandlerClass = PACKAGE_NAME + ".ComponentListAttribute";
+
+ String listHandlerClass = PACKAGE_NAME + ".definition.ComponentListAttribute";
// Tag value for adding an element in a list
String ADD_LIST_ELE_TAG = "*/" + LIST_TAG + "/add";
// syntax rules
- digester.addObjectCreate( DEFINITION_TAG, definitionHandlerClass );
- digester.addSetProperties( DEFINITION_TAG);
- digester.addSetNext( DEFINITION_TAG, "addDefinition", definitionHandlerClass);
+ digester.addObjectCreate(DEFINITION_TAG, definitionHandlerClass);
+ digester.addSetProperties(DEFINITION_TAG);
+ digester.addSetNext(DEFINITION_TAG, "addDefinition", definitionHandlerClass);
// put / putAttribute rules
// Rules for a same pattern are called in order, but rule.end() are called
// in reverse order.
// SetNext and CallMethod use rule.end() method. So, placing SetNext in
// first position ensure it will be called last (sic).
- digester.addObjectCreate( PUT_TAG, putAttributeHandlerClass);
- digester.addSetProperties( PUT_TAG);
- digester.addSetNext( PUT_TAG, "addAttribute", putAttributeHandlerClass);
- digester.addCallMethod( PUT_TAG, "setBody", 0);
+ digester.addObjectCreate(PUT_TAG, putAttributeHandlerClass);
+ digester.addSetProperties(PUT_TAG);
+ digester.addSetNext(PUT_TAG, "addAttribute", putAttributeHandlerClass);
+ digester.addCallMethod(PUT_TAG, "setBody", 0);
// Definition level list rules
// This is rules for lists nested in a definition
- digester.addObjectCreate( DEF_LIST_TAG, listHandlerClass);
- digester.addSetProperties( DEF_LIST_TAG);
- digester.addSetNext( DEF_LIST_TAG, "addAttribute", putAttributeHandlerClass);
+ digester.addObjectCreate(DEF_LIST_TAG, listHandlerClass);
+ digester.addSetProperties(DEF_LIST_TAG);
+ digester.addSetNext(DEF_LIST_TAG, "addAttribute", putAttributeHandlerClass);
// list elements rules
// We use Attribute class to avoid rewriting a new class.
// Name part can't be used in listElement attribute.
- digester.addObjectCreate( ADD_LIST_ELE_TAG, putAttributeHandlerClass);
- digester.addSetProperties( ADD_LIST_ELE_TAG);
- digester.addSetNext( ADD_LIST_ELE_TAG, "add", putAttributeHandlerClass);
- digester.addCallMethod( ADD_LIST_ELE_TAG, "setBody", 0);
+ digester.addObjectCreate(ADD_LIST_ELE_TAG, putAttributeHandlerClass);
+ digester.addSetProperties(ADD_LIST_ELE_TAG);
+ digester.addSetNext(ADD_LIST_ELE_TAG, "add", putAttributeHandlerClass);
+ digester.addCallMethod(ADD_LIST_ELE_TAG, "setBody", 0);
// nested list elements rules
// Create a list handler, and add it to parent list
String NESTED_LIST = "*/" + LIST_TAG + "/" + LIST_TAG;
- digester.addObjectCreate( NESTED_LIST, listHandlerClass);
- digester.addSetProperties( NESTED_LIST);
- digester.addSetNext( NESTED_LIST, "add", putAttributeHandlerClass);
+ digester.addObjectCreate(NESTED_LIST, listHandlerClass);
+ digester.addSetProperties(NESTED_LIST);
+ digester.addSetNext(NESTED_LIST, "add", putAttributeHandlerClass);
// item elements rules
// We use Attribute class to avoid rewriting a new class.
@@ -251,19 +256,19 @@
// non String ADD_WILDCARD = LIST_TAG + "/addx*";
String ADD_WILDCARD = "*/item";
String menuItemDefaultClass = "org.apache.tiles.beans.SimpleMenuItem";
- digester.addObjectCreate( ADD_WILDCARD, menuItemDefaultClass, "classtype");
- digester.addSetNext( ADD_WILDCARD, "add", "java.lang.Object");
- digester.addSetProperties( ADD_WILDCARD);
+ digester.addObjectCreate(ADD_WILDCARD, menuItemDefaultClass, "classtype");
+ digester.addSetNext(ADD_WILDCARD, "add", "java.lang.Object");
+ digester.addSetProperties(ADD_WILDCARD);
// bean elements rules
String BEAN_TAG = "*/bean";
String beanDefaultClass = "org.apache.tiles.beans.SimpleMenuItem";
- digester.addObjectCreate( BEAN_TAG, beanDefaultClass, "classtype");
- digester.addSetProperties( BEAN_TAG);
- digester.addSetNext( BEAN_TAG, "add", "java.lang.Object");
+ digester.addObjectCreate(BEAN_TAG, beanDefaultClass, "classtype");
+ digester.addSetProperties(BEAN_TAG);
+ digester.addSetNext(BEAN_TAG, "add", "java.lang.Object");
// Set properties to surrounding element
- digester.addSetProperty(BEAN_TAG+ "/set-property", "property", "value");
+ digester.addSetProperty(BEAN_TAG + "/set-property", "property", "value");
}
/**
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/factory/ConfigurationNotSupportedException.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/factory/ConfigurationNotSupportedException.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/factory/ConfigurationNotSupportedException.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/factory/ConfigurationNotSupportedException.java Wed Nov 1 18:03:00 2006
@@ -21,7 +21,7 @@
/**
*
- *
+ *
*/
public class ConfigurationNotSupportedException extends TilesException {
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/factory/TilesContainerFactory.java Wed Nov 1 18:03:00 2006
@@ -17,19 +17,19 @@
*/
package org.apache.tiles.factory;
+import org.apache.tiles.TilesApplicationContext;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.TilesException;
-import org.apache.tiles.DefinitionsFactory;
-import org.apache.tiles.TilesApplicationContext;
-import org.apache.tiles.definition.UrlDefinitionsFactory;
-import org.apache.tiles.context.TilesContextFactory;
import org.apache.tiles.context.BasicTilesContextFactory;
+import org.apache.tiles.context.TilesContextFactory;
+import org.apache.tiles.definition.DefinitionsFactory;
+import org.apache.tiles.definition.UrlDefinitionsFactory;
import org.apache.tiles.impl.BasicTilesContainer;
import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.HashMap;
import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
/**
* Factory provided for convenience.
@@ -42,13 +42,13 @@
public class TilesContainerFactory {
public static final String CONTAINER_FACTORY_INIT_PARAM =
- "org.apache.tiles.CONTAINER_FACTORY";
+ "org.apache.tiles.CONTAINER_FACTORY";
public static final String CONTEXT_FACTORY_INIT_PARAM =
- "org.apache.tiles.CONTEXT_FACTORY";
+ "org.apache.tiles.CONTEXT_FACTORY";
public static final String DEFINITIONS_FACTORY_INIT_PARAM =
- "org.apache.tiles.DEFINITIONS_FACTORY";
+ "org.apache.tiles.DEFINITIONS_FACTORY";
private static final Map DEFAULT_IMPLEMENTATIONS = new HashMap();
@@ -73,18 +73,18 @@
* @throws TilesException
*/
public static TilesContainerFactory getFactory(Object context)
- throws TilesException {
+ throws TilesException {
return (TilesContainerFactory) TilesContainerFactory
- .createFactory(context, CONTAINER_FACTORY_INIT_PARAM);
+ .createFactory(context, CONTAINER_FACTORY_INIT_PARAM);
}
public TilesContainer createContainer(Object context)
- throws TilesException {
+ throws TilesException {
BasicTilesContainer container = new BasicTilesContainer();
TilesContextFactory contextFactory =
- (TilesContextFactory)createFactory(context, CONTEXT_FACTORY_INIT_PARAM);
+ (TilesContextFactory) createFactory(context, CONTEXT_FACTORY_INIT_PARAM);
DefinitionsFactory defsFactory =
(DefinitionsFactory) createFactory(context, DEFINITIONS_FACTORY_INIT_PARAM);
@@ -102,29 +102,29 @@
public Map getInitParameterMap(Object context)
- throws TilesException {
+ throws TilesException {
Map initParameters = new HashMap();
Class contextClass = context.getClass();
try {
Method method = contextClass.getMethod("getInitParameterNames");
- Enumeration e = (Enumeration)method.invoke(context);
+ Enumeration e = (Enumeration) method.invoke(context);
method = contextClass.getMethod("getInitParameter", String.class);
- while(e.hasMoreElements()) {
- String key = (String)e.nextElement();
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement();
initParameters.put(key, method.invoke(context, key));
}
} catch (Exception e) {
throw new TilesException("Unable to retrieve init parameters." +
- " Is this context a ServletContext, PortletContext," +
- " or similar object?");
+ " Is this context a ServletContext, PortletContext," +
+ " or similar object?");
}
return initParameters;
}
public static Object createFactory(Object context, String initParameterName)
- throws TilesException {
+ throws TilesException {
String factoryName = resolveFactoryName(context, initParameterName);
try {
Class factoryClass = Class.forName(factoryName);
@@ -135,25 +135,25 @@
throw new TilesException("Unable to access factory class: '" + factoryName + "'");
} catch (InstantiationException e) {
throw new TilesException("Unable to instantiate factory class: '"
- + factoryName + "'. Make sure that this class has a default constructor");
+ + factoryName + "'. Make sure that this class has a default constructor");
}
}
public static String resolveFactoryName(Object context, String parameterName)
- throws TilesException {
+ throws TilesException {
Object factoryName = null;
try {
Class contextClass = context.getClass();
Method getInitParameterMethod =
- contextClass.getMethod("getInitParameter", String.class);
+ contextClass.getMethod("getInitParameter", String.class);
factoryName = getInitParameterMethod.invoke(context, parameterName);
} catch (Exception e) {
throw new TilesException("Unrecognized context. Is this context" +
- "a ServletContext, PortletContext, or similar?", e);
+ "a ServletContext, PortletContext, or similar?", e);
}
return factoryName == null
- ? DEFAULT_IMPLEMENTATIONS.get(parameterName).toString()
- : factoryName.toString();
+ ? DEFAULT_IMPLEMENTATIONS.get(parameterName).toString()
+ : factoryName.toString();
}
}
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java Wed Nov 1 18:03:00 2006
@@ -18,17 +18,17 @@
package org.apache.tiles.filter;
-import java.io.IOException;
-import javax.servlet.*;
+import org.apache.tiles.definition.DefinitionsFactory;
+import org.apache.tiles.definition.ReloadableDefinitionsFactory;
+import org.apache.tiles.util.TilesUtil;
-import org.apache.tiles.DefinitionsFactory;
-import org.apache.tiles.ReloadableDefinitionsFactory;
-import org.apache.tiles.TilesUtil;
+import javax.servlet.*;
+import java.io.IOException;
/**
* Processes Reloadable Tiles Definitions.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date$
*/
public class TilesFilter implements Filter {
@@ -46,16 +46,15 @@
/**
* Checks whether Tiles Definitions need to be reloaded.
*
- * @param request The servlet request we are processing
+ * @param request The servlet request we are processing
* @param response The servlet response we are creating
- * @param chain The filter chain we are processing
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet error occurs
+ * @param chain The filter chain we are processing
+ * @throws IOException if an input/output error occurs
+ * @throws ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
- throws IOException, ServletException {
+ throws IOException, ServletException {
try {
DefinitionsFactory factory = TilesUtil.getDefinitionsFactory();
@@ -66,7 +65,7 @@
}
}
chain.doFilter(request, response);
- } catch(Exception e) {
+ } catch (Exception e) {
throw new ServletException("Error processing request.", e);
}
}
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java Wed Nov 1 18:03:00 2006
@@ -17,20 +17,25 @@
*/
package org.apache.tiles.impl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.tiles.*;
-import org.apache.tiles.preparer.PreparerFactory;
-import org.apache.tiles.preparer.PreparerException;
import org.apache.tiles.context.TilesContextFactory;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
+import org.apache.tiles.definition.ComponentDefinition;
+import org.apache.tiles.definition.DefinitionsFactory;
+import org.apache.tiles.definition.DefinitionsFactoryException;
+import org.apache.tiles.definition.NoSuchDefinitionException;
+import org.apache.tiles.preparer.PreparerException;
+import org.apache.tiles.preparer.PreparerFactory;
+import org.apache.tiles.preparer.ViewPreparer;
import javax.servlet.jsp.PageContext;
-import java.util.Map;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.ArrayList;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
/**
* Basic implementation of the tiles container interface.
@@ -61,7 +66,7 @@
* instances.
*/
private static final Log LOG =
- LogFactory.getLog(BasicTilesContainer.class);
+ LogFactory.getLog(BasicTilesContainer.class);
private TilesApplicationContext context;
private DefinitionsFactory definitionsFactory;
@@ -94,7 +99,7 @@
}
} catch (MalformedURLException e) {
throw new DefinitionsFactoryException("Unable to parse definitions from "
- + resourceString, e);
+ + resourceString, e);
}
}
@@ -123,9 +128,9 @@
public TilesRequestContext getRequestContext(Object request, Object response) {
return getContextFactory().createRequestContext(
- getApplicationContext(),
- request,
- response
+ getApplicationContext(),
+ request,
+ response
);
}
@@ -179,19 +184,19 @@
}
public void prepare(Object request, Object response, String preparer)
- throws TilesException {
+ throws TilesException {
TilesRequestContext requestContext = getContextFactory().createRequestContext(
- getApplicationContext(),
- request,
- response
+ getApplicationContext(),
+ request,
+ response
);
prepare(requestContext, preparer);
}
public void prepare(PageContext context, String preparer)
- throws TilesException {
+ throws TilesException {
TilesRequestContext requestContext = getContextFactory().createRequestContext(
- getApplicationContext(), context
+ getApplicationContext(), context
);
prepare(requestContext, preparer);
}
@@ -201,12 +206,11 @@
ViewPreparer preparer = preparerFactory.getPreparer(preparerName, null);
ComponentContext componentContext = ComponentContext.getContext(context);
-
// TODO: Temporary while preparer gets refactored to throw a more specific exception.
try {
preparer.execute(context, componentContext);
} catch (Exception e) {
- throw new PreparerException(e.getMessage(), e);
+ throw new PreparerException(e.getMessage(), e);
}
}
@@ -217,27 +221,27 @@
* @throws TilesException
*/
public void render(Object request, Object response, String definitionName)
- throws TilesException {
+ throws TilesException {
TilesRequestContext requestContext = getContextFactory().createRequestContext(
- getApplicationContext(),
- request,
- response
+ getApplicationContext(),
+ request,
+ response
);
render(requestContext, definitionName);
}
public void render(PageContext context, String definitionName)
- throws TilesException {
+ throws TilesException {
TilesRequestContext requestContext = getContextFactory().createRequestContext(
- getApplicationContext(), context
+ getApplicationContext(), context
);
render(requestContext, definitionName);
}
private void render(TilesRequestContext request, String definitionName)
- throws TilesException {
+ throws TilesException {
ComponentDefinition definition =
- definitionsFactory.getDefinition(definitionName, request);
+ definitionsFactory.getDefinition(definitionName, request);
if (definition == null) {
if (LOG.isWarnEnabled()) {
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/listener/TilesContainerListener.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/listener/TilesContainerListener.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/listener/TilesContainerListener.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/listener/TilesContainerListener.java Wed Nov 1 18:03:00 2006
@@ -17,25 +17,25 @@
*/
package org.apache.tiles.listener;
-import org.apache.tiles.factory.TilesContainerFactory;
-import org.apache.tiles.TilesException;
-import org.apache.tiles.TilesContainer;
-import org.apache.tiles.access.TilesAccess;
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.factory.TilesContainerFactory;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
public class TilesContainerListener
- implements ServletContextListener {
+ implements ServletContextListener {
/**
* Log instance.
*/
protected static final Log LOG =
- LogFactory.getLog(TilesListener.class);
+ LogFactory.getLog(TilesListener.class);
/**
* Initialize the TilesContainer and place it
@@ -49,13 +49,14 @@
TilesContainer container = createContainer(servletContext);
TilesAccess.setContainer(servletContext, container);
} catch (TilesException e) {
- LOG.fatal("Unable to retrieve tiles factory.",e);
+ LOG.fatal("Unable to retrieve tiles factory.", e);
throw new IllegalStateException("Unable to instantiate container.");
}
}
/**
* Remove the tiles container from service.
+ *
* @param event
*/
public void contextDestroyed(ServletContextEvent event) {
@@ -70,7 +71,7 @@
protected TilesContainer createContainer(ServletContext context)
throws TilesException {
TilesContainerFactory factory =
- TilesContainerFactory.getFactory(context);
+ TilesContainerFactory.getFactory(context);
return factory.createContainer(context);
}
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java Wed Nov 1 18:03:00 2006
@@ -18,21 +18,23 @@
package org.apache.tiles.listener;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Enumeration;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletException;
-import javax.servlet.UnavailableException;
-
-import org.apache.tiles.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.TilesException;
import org.apache.tiles.access.TilesAccess;
import org.apache.tiles.context.BasicTilesContextFactory;
import org.apache.tiles.context.TilesContextFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.definition.DefinitionsFactory;
+import org.apache.tiles.definition.DefinitionsFactoryConfig;
+import org.apache.tiles.definition.DefinitionsFactoryException;
+import org.apache.tiles.util.TilesUtil;
+import org.apache.tiles.util.TilesUtilImpl;
+
+import javax.servlet.*;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
/**
* @version $Rev$ $Date$
@@ -41,39 +43,39 @@
/**
* The LOG for this class
- */
- private static final Log LOG = LogFactory.getLog(TilesListener.class);
+ */
+ private static final Log LOG = LogFactory.getLog(TilesListener.class);
/**
* The default name of a context init parameter that specifies the Tiles configuration file
- */
+ */
private static final String DEFAULT_CONFIG_FILE_PARAM = "definitions-config";
/**
* The default name of the Tiles configuration file
- */
+ */
private static final String DEFAULT_CONFIG_FILE = "/WEB-INF/tiles.xml";
/**
* An error message stating that something went wrong during initialization
- */
+ */
private static final String CANT_POPULATE_FACTORY_ERROR =
- "CAN'T POPULATE TILES DEFINITION FACTORY";
+ "CAN'T POPULATE TILES DEFINITION FACTORY";
/**
* The Tiles definition impl
- */
- protected DefinitionsFactory definitionFactory = null;
+ */
+ protected DefinitionsFactory definitionFactory = null;
/**
* A comma-separated list of filenames representing the
* application's Tiles configuration files.
- */
+ */
private String configFiles = null;
public void contextInitialized(ServletContextEvent event) {
@@ -93,9 +95,9 @@
TilesUtil.setTilesUtil(new TilesUtilImpl(tilesContext));
initDefinitionsFactory(context, fconfig);
}
- catch(Exception ex) {
+ catch (Exception ex) {
saveExceptionMessage(event.getServletContext(), ex);
- throw new RuntimeException(ex.getMessage(), ex);
+ throw new RuntimeException(ex.getMessage(), ex);
}
}
@@ -125,14 +127,13 @@
Map map = new HashMap();
try {
- if(configFiles != null) {
+ if (configFiles != null) {
LOG.info("CONFIG FILES DEFINED IN WEB.XML");
- map.put(DEFAULT_CONFIG_FILE_PARAM, configFiles);
- }
- else {
+ map.put(DEFAULT_CONFIG_FILE_PARAM, configFiles);
+ } else {
LOG.info("CONFIG FILES WERE NOT DEFINED IN WEB.XML, " +
- "LOOKING FOR " + DEFAULT_CONFIG_FILE);
- map.put(DEFAULT_CONFIG_FILE_PARAM, DEFAULT_CONFIG_FILE);
+ "LOOKING FOR " + DEFAULT_CONFIG_FILE);
+ map.put(DEFAULT_CONFIG_FILE_PARAM, DEFAULT_CONFIG_FILE);
}
populateConfigParameterMap(context, map);
@@ -140,7 +141,7 @@
}
catch (Exception ex) {
saveExceptionMessage(context, ex);
- throw new UnavailableException(CANT_POPULATE_FACTORY_ERROR + ex.getMessage());
+ throw new UnavailableException(CANT_POPULATE_FACTORY_ERROR + ex.getMessage());
}
return factoryConfig;
}
@@ -150,11 +151,11 @@
* Initializes the Tiles definitions impl.
*
* @param servletContext The servlet context
- * @param factoryConfig The definitions impl config
+ * @param factoryConfig The definitions impl config
*/
- private void initDefinitionsFactory(ServletContext servletContext,
- DefinitionsFactoryConfig factoryConfig)
- throws ServletException {
+ private void initDefinitionsFactory(ServletContext servletContext,
+ DefinitionsFactoryConfig factoryConfig)
+ throws ServletException {
LOG.info("initializing definitions impl...");
// Create configurable impl
try {
@@ -162,7 +163,7 @@
definitionFactory = TilesUtil.createDefinitionsFactory(factoryConfig);
} catch (DefinitionsFactoryException ex) {
- ex.printStackTrace();
+ ex.printStackTrace();
throw new ServletException(ex.getMessage(), ex);
}
}
@@ -175,19 +176,19 @@
* activated.
*
* @param context The servlet configuration
- * @param ex An exception
+ * @param ex An exception
*/
private void saveExceptionMessage(ServletContext context, Exception ex) {
- LOG.warn("Caught exception when initializing definitions impl");
- LOG.warn(ex.getMessage());
- LOG.warn(ex.toString());
- context.setAttribute("TILES_INIT_EXCEPTION", ex.getMessage());
+ LOG.warn("Caught exception when initializing definitions impl");
+ LOG.warn(ex.getMessage());
+ LOG.warn(ex.toString());
+ context.setAttribute("TILES_INIT_EXCEPTION", ex.getMessage());
}
/**
* Populates a map with the parameters contained in the context configuration.
*
- * @param context The servlet context
+ * @param context The servlet context
* @param paramMap The map to fill
*/
private void populateConfigParameterMap(ServletContext context, Map paramMap) {
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/package.html
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/package.html?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/package.html (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/package.html Wed Nov 1 18:03:00 2006
@@ -1,49 +1,68 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html lang="en">
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html lang="en">
<head>
-<title>Tiles Package</title>
+ <title>Tiles Package</title>
</head>
<body>
<div class="mainContent">
- The Tiles taglib and framework allows building web pages by assembling reusable
- pieces of pages, called Tiles. A Tiles is usually a simple JSP page.
+The Tiles taglib and framework allows building web pages by assembling reusable
+pieces of pages, called Tiles. A Tiles is usually a simple JSP page.
<div class="section">
-<h2>Introduction</h2>
- <p>The Tiles framework allows building pages by assembling reusable Tiles.
- As an example, the page in the next figure can be build by assembling a
- header, a footer, a menu and a body.</p>
+ <h2>Introduction</h2>
+
+ <p>The Tiles framework allows building pages by assembling reusable Tiles.
+ As an example, the page in the next figure can be build by assembling a
+ header, a footer, a menu and a body.</p>
+
<p><img src="doc-files/image001.gif" height="169" width="145" alt="doc-files/image001"></p>
- <p>Each Tiles (header, menu, body, ...) is a JSP page and can itself be build
- by assembling other Tiles.</p>
-<p>Using Tiles can be compared as using Java methods: You need to define the Tiles (the method body), and then you can "call" this body anywhere you want, passing it some parameters. In Tiles, parameters are called "attributes" in order to avoid confusion with the request parameters.</p>
- <p>The Tiles body can be a simple JSP page, a Struts action or any URI pointing
- to a resource inside the current web site.</p>
- <p>Inserting the body, or calling it, is done with the tag <tiles:insert
- ...> anywhere in a JSP page. Insertion can also be done by specifying
- a <em>definition name </em>as the path of a Struts forward or as input,
- forward or include attributes of a Struts action.</p>
- <p>Tiles bodies are used to create layouts, reusable parts, ... Tiles insertions
- are used to insert Tiles. The same Tiles can be reused several times in
- the same site, or even in the same page.</p>
-<p>Insertion of a Tiles body can be associated to a logical name in what Tiles calls a "definition". A definition contains a logical name, a page used as body and some attribute values. The definition declaration doesn't insert the associated Tiles body. It just associates it with the name. A definition name can be used anywhere insertion of a Tiles body can occur. The associated Tiles body is then inserted with associated attributes.</p>
- <p>The definition declarations can be done in JSP pages or in one or more
- centralized files. A definition can extend another one, overload some attributes,
- add new attributes ... This allows the declaration of a "master" definition
- declaring the common layout, header, menu and footer. All other definitions
- extend this master layout thereby making it possible to change the entire
- site look & feel simply by changing the master definition. </p>
+
+ <p>Each Tiles (header, menu, body, ...) is a JSP page and can itself be build
+ by assembling other Tiles.</p>
+
+ <p>Using Tiles can be compared as using Java methods: You need to define the Tiles (the method body), and then you
+ can "call" this body anywhere you want, passing it some parameters. In Tiles, parameters are called
+ "attributes" in order to avoid confusion with the request parameters.</p>
+
+ <p>The Tiles body can be a simple JSP page, a Struts action or any URI pointing
+ to a resource inside the current web site.</p>
+
+ <p>Inserting the body, or calling it, is done with the tag <tiles:insert
+ ...> anywhere in a JSP page. Insertion can also be done by specifying
+ a <em>definition name </em>as the path of a Struts forward or as input,
+ forward or include attributes of a Struts action.</p>
+
+ <p>Tiles bodies are used to create layouts, reusable parts, ... Tiles insertions
+ are used to insert Tiles. The same Tiles can be reused several times in
+ the same site, or even in the same page.</p>
+
+ <p>Insertion of a Tiles body can be associated to a logical name in what Tiles calls a "definition". A
+ definition contains a logical name, a page used as body and some attribute values. The definition declaration
+ doesn't insert the associated Tiles body. It just associates it with the name. A definition name can be used
+ anywhere insertion of a Tiles body can occur. The associated Tiles body is then inserted with associated
+ attributes.</p>
+
+ <p>The definition declarations can be done in JSP pages or in one or more
+ centralized files. A definition can extend another one, overload some attributes,
+ add new attributes ... This allows the declaration of a "master" definition
+ declaring the common layout, header, menu and footer. All other definitions
+ extend this master layout thereby making it possible to change the entire
+ site look & feel simply by changing the master definition. </p>
</div>
<div class="section">
-<h2>Simple Examples</h2>
-<div class="subsection1">
- <h3>Insert a JSP page</h3>
+ <h2>Simple Examples</h2>
+
+ <div class="subsection1">
+ <h3>Insert a JSP page</h3>
<pre><tiles:insert <strong>page</strong>="/layouts/commonLayout.jsp" flush="true" />
</pre>
-<p>This example inserts the specified page in place of the tag. The page attribute is any valid URL pointing to a resource inside the current site.</p>
-</div>
-<div class="subsection1">
-<a name="doc.InsertPageWithAttributes"></a>
-<h3>Insert a Tiles passing some attributes</h3>
+ <p>This example inserts the specified page in place of the tag. The page attribute is any valid URL pointing to
+ a resource inside the current site.</p>
+ </div>
+ <div class="subsection1">
+ <a name="doc.InsertPageWithAttributes"></a>
+
+ <h3>Insert a Tiles passing some attributes</h3>
<pre>
<tiles:insert page="/layouts/classicLayout.jsp" flush=&quot;true">
<tiles:put name="title" value="Page Title" />
@@ -53,30 +72,33 @@
<tiles:put name="body" value="/tiles/mainBody.jsp" />
</tiles:insert>
</pre>
- <p>This example inserts the specified page, passing it the attributes. Attributes
- are stored in a Tiles context which is passed to the inserted pag and
- can then be accesssed by their names.</p>
-</div>
-<div class="subsection1">
-<h3>Retrieve an attribute value as String</h3>
+ <p>This example inserts the specified page, passing it the attributes. Attributes
+ are stored in a Tiles context which is passed to the inserted pag and
+ can then be accesssed by their names.</p>
+ </div>
+ <div class="subsection1">
+ <h3>Retrieve an attribute value as String</h3>
<pre>
<tiles:getAsString name="title" />
</pre>
-<p>This example retrieves the value of the attribute "title" and prints it as a String in the current output stream. The method toString() is applied on the attribute value, allowing to pass any kind of object as value.</p>
-</div>
-<div class="subsection1">
-<h3>Insert Tiles referenced by an attribute</h3>
+ <p>This example retrieves the value of the attribute "title" and prints it as a String in the current
+ output stream. The method toString() is applied on the attribute value, allowing to pass any kind of object
+ as value.</p>
+ </div>
+ <div class="subsection1">
+ <h3>Insert Tiles referenced by an attribute</h3>
<pre>
<tiles:insert attribute='menu' />
</pre>
- <p>This inserts the Tiles referenced by the attribute "menu" value. The
- specified attribute value is first retrieved from current Tiles's context,
- and then the value is used as a page target to insert.</p>
-</div>
-<div class="subsection1">
-<h3>Classic Layout </h3>
- <p>This example is a layout assembling a page in the classic header-footer-menu-body
- fashion.</p>
+ <p>This inserts the Tiles referenced by the attribute "menu" value. The
+ specified attribute value is first retrieved from current Tiles's context,
+ and then the value is used as a page target to insert.</p>
+ </div>
+ <div class="subsection1">
+ <h3>Classic Layout </h3>
+
+ <p>This example is a layout assembling a page in the classic header-footer-menu-body
+ fashion.</p>
<pre>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<HTML>
@@ -107,41 +129,50 @@
</body>
</html>
</pre>
- <p>The layout is declared in a JSP page (ex: /layouts/classicLayout.jsp).
- It can be used in conjunction with the tag described in "<a href="#doc.InsertPageWithAttributes">Insert
- a page passing some attributes</a>". </p>
-</div>
+ <p>The layout is declared in a JSP page (ex: /layouts/classicLayout.jsp).
+ It can be used in conjunction with the tag described in "<a href="#doc.InsertPageWithAttributes">Insert
+ a page passing some attributes</a>". </p>
+ </div>
</div>
<div class="section">
<h2>Definitions</h2>
- <p>A definition associates a logical name with the URL of a Tiles to be inserted
- and some attribute values. A definition doesn't insert the Tiles. This is
- done later using the definition name. A definition name can be inserted
- as often as you want in your site, making it easy to reuse a Tiles. </p>
- <p>A definition can extend another definition and overload some attributes
- or add new ones. This makes easy factorization of definitions differing
- by some attributes. For example, you can define a master definition declaring
- the main header, menu, footer, and a default title. Then let each of your
- page definitions extend this master definition and overload the title and
- the body.</p>
- <p>Definitions can be declared in a JSP page, or in one or more centralized
- files. To enable the definitions from centralized files, you need to initialize
- the "definitions factory&&quot; which will parse the definitions from the files
- and provide them to the Tiles framework.</p>
+
+<p>A definition associates a logical name with the URL of a Tiles to be inserted
+ and some attribute values. A definition doesn't insert the Tiles. This is
+ done later using the definition name. A definition name can be inserted
+ as often as you want in your site, making it easy to reuse a Tiles. </p>
+
+<p>A definition can extend another definition and overload some attributes
+ or add new ones. This makes easy factorization of definitions differing
+ by some attributes. For example, you can define a master definition declaring
+ the main header, menu, footer, and a default title. Then let each of your
+ page definitions extend this master definition and overload the title and
+ the body.</p>
+
+<p>Definitions can be declared in a JSP page, or in one or more centralized
+ files. To enable the definitions from centralized files, you need to initialize
+ the "definitions factory&&quot; which will parse the definitions from the files
+ and provide them to the Tiles framework.</p>
+
<div class="subsection1">
<h3>Enabling Definition Factory</h3>
-<p>To enable Tiles definitions described in one or more files, you need to write these files and to initialize the definition factory. </p>
- <p>Initialization is different depending on the Struts version you use,
- or if you do not use Struts at all.</p>
+
+<p>To enable Tiles definitions described in one or more files, you need to write these files and to initialize the
+ definition factory. </p>
+
+<p>Initialization is different depending on the Struts version you use,
+ or if you do not use Struts at all.</p>
+
<div class="subsection2">
-<h4>Struts1.1</h4>
- <p>Use the Tiles plug-in to enable Tiles definitions. This plug-in creates
- the definition factory and passese it a configuration object populated
- with parameters. Parameters can be specified in the web.xml file or
- as plug-in parameters. The plug-in first reads parameters from web.xml,
- and then overloads them with the ones found in the plug-in. All parameters
- are optional and can be omitted. The plug-in should be declared in each
- struts-config file:</p>
+ <h4>Struts1.1</h4>
+
+ <p>Use the Tiles plug-in to enable Tiles definitions. This plug-in creates
+ the definition factory and passese it a configuration object populated
+ with parameters. Parameters can be specified in the web.xml file or
+ as plug-in parameters. The plug-in first reads parameters from web.xml,
+ and then overloads them with the ones found in the plug-in. All parameters
+ are optional and can be omitted. The plug-in should be declared in each
+ struts-config file:</p>
<pre>
<plug-in className=&&quot;org.apache.struts.tiles.TilesPlugin&&quot; >
<set-property property=&&quot;definitions-config&&quot;
@@ -152,70 +183,79 @@
<set-property property=&&quot;definitions-parser-validate&&quot; value=&&quot;true&&quot; />
</plug-in>
</pre>
-<ul>
-<li>definitions-config: (optional) <ul>
-<li>Specify configuration file names. There can be several comma separated file names (default: ?? )</li>
-</ul>
-</li>
- <li>definitions-parser-validate: (optional)
-<ul>
- <li>Specify if XML parser should validate the Tiles configuration
- file
- <ul>
- <li>true : validate. DTD should be specified in file header (default)</li>
-<li>false : no validation </li>
-
-</ul>
-</li>
-</ul>
-</li>
-
- <li>moduleAware: (optional)
- <ul>
- <li>Specify if the Tiles definition factory is module aware. If true (default),
- there will be one factory for each Struts module.
- If false, there will be one common factory for all module. In this later case,
- it is still needed to declare one plugin per module. The factory will be
- initialized with parameters found in the first initialized plugin (generally the
- one associated with the default module).
+ <ul>
+ <li>definitions-config: (optional)
+ <ul>
+ <li>Specify configuration file names. There can be several comma separated file names (default: ?? )
+ </li>
+ </ul>
+ </li>
+ <li>definitions-parser-validate: (optional)
+ <ul>
+ <li>Specify if XML parser should validate the Tiles configuration
+ file
+ <ul>
+ <li>true : validate. DTD should be specified in file header (default)</li>
+ <li>false : no validation</li>
+
+ </ul>
+ </li>
+ </ul>
+ </li>
+
+ <li>moduleAware: (optional)
<ul>
- <li>true : Tiles framework is module aware </li>
- <li>false :Tiles framework has one single factoy shared among modules (default)</li>
+ <li>Specify if the Tiles definition factory is module aware. If true (default),
+ there will be one factory for each Struts module.
+ If false, there will be one common factory for all module. In this later case,
+ it is still needed to declare one plugin per module. The factory will be
+ initialized with parameters found in the first initialized plugin (generally the
+ one associated with the default module).
+ <ul>
+ <li>true : Tiles framework is module aware</li>
+ <li>false :Tiles framework has one single factoy shared among modules (default)</li>
+ </ul>
+ </li>
</ul>
- </li>
-</ul>
-</li>
-
-<li>tilesUtilImplClassname: (optional - for advanced user)
- <ul>
- <li>Specify The classname of the TilesUtil implementation to use. The specified class should
- be a subclass of TilesUtilStrutsImpl. This option disable the moduleAware option.
- <br>Specifying &&quot;TilesUtilStrutsImpl&&quot; is equivalent to moduleAware = false.</br>
- <br>Specifying &&quot;TilesUtilStrutsModuleImpl&&quot; is equivalent to moduleAware = true.</br>
- This option is taken into account only once, when it is first encountered. To avoid problems,
- it is advice to specify the same values in all TilesPlugin declaration.
- </li>
- </ul>
-</li>
-
-</ul>
- <p>The TilesPlugin class creates one definition factory for each struts module.
- </p>
- <p>
- If the flag moduleAware is false, only one shared factory is created for all modules.
- In this later case, the factory is initialized with parameters found in the first plugin.
- The plugins should be declared in all modules, and the moduleAware flag should be
- the same for the entire application.</p>
- <p>
- Paths found in Tiles definitions are relative to the main context.</p>
- <p>You don't need to specify a TilesRequestProcessor, this is automatically
- done by the plug-in. If, however, you want to specify your own RequestProcessor,
- it should extend the TilesRequestProcessor. The plug-in checks this
- constraint.</p>
+ </li>
+
+ <li>tilesUtilImplClassname: (optional - for advanced user)
+ <ul>
+ <li>Specify The classname of the TilesUtil implementation to use. The specified class should
+ be a subclass of TilesUtilStrutsImpl. This option disable the moduleAware option.
+ <br>Specifying &&quot;TilesUtilStrutsImpl&&quot; is equivalent to moduleAware =
+ false.</br>
+ <br>Specifying &&quot;TilesUtilStrutsModuleImpl&&quot; is equivalent to moduleAware
+ = true.</br>
+ This option is taken into account only once, when it is first encountered. To avoid problems,
+ it is advice to specify the same values in all TilesPlugin declaration.
+ </li>
+ </ul>
+ </li>
+
+ </ul>
+ <p>The TilesPlugin class creates one definition factory for each struts module.
+ </p>
+
+ <p>
+ If the flag moduleAware is false, only one shared factory is created for all modules.
+ In this later case, the factory is initialized with parameters found in the first plugin.
+ The plugins should be declared in all modules, and the moduleAware flag should be
+ the same for the entire application.</p>
+
+ <p>
+ Paths found in Tiles definitions are relative to the main context.</p>
+
+ <p>You don't need to specify a TilesRequestProcessor, this is automatically
+ done by the plug-in. If, however, you want to specify your own RequestProcessor,
+ it should extend the TilesRequestProcessor. The plug-in checks this
+ constraint.</p>
</div>
<div class="subsection2">
-<h4>Struts1.0.x</h4>
-<p>You need to use a special servlet extending the Struts servlet. This is specified in the web.xml file of your application:</p>
+ <h4>Struts1.0.x</h4>
+
+ <p>You need to use a special servlet extending the Struts servlet. This is specified in the web.xml file of your
+ application:</p>
<pre>
<servlet>
<servlet-name>action</servlet-name>
@@ -242,8 +282,10 @@
</pre>
</div>
<div class="subsection2">
-<h4>Without Struts</h4>
-<p>Tiles can be used without Struts. To initialize the definition factory, you can use the provided servlet. Declare it in the web.xml file of your application:</p>
+ <h4>Without Struts</h4>
+
+ <p>Tiles can be used without Struts. To initialize the definition factory, you can use the provided servlet. Declare
+ it in the web.xml file of your application:</p>
<pre>
<servlet>
<servlet-name>action</servlet-name>
@@ -260,15 +302,17 @@
</init-param>
...
</pre>
-<p>The parameters are the same as for Struts1.1 or 1.0.</p>
+ <p>The parameters are the same as for Struts1.1 or 1.0.</p>
</div>
</div>
<div class="subsection1">
-<h3>Definition File Syntax</h3>
-<p>The definition file syntax can be found in the
-<a href="http://struts.apache.org/dtds/tiles-config_1_1.dtd">tiles-config_1_1.dtd file</a>.
-</p>
-<p>Following is a simple example:</p>
+ <h3>Definition File Syntax</h3>
+
+ <p>The definition file syntax can be found in the
+ <a href="http://struts.apache.org/dtds/tiles-config_1_1.dtd">tiles-config_1_1.dtd file</a>.
+ </p>
+
+ <p>Following is a simple example:</p>
<pre>
<!DOCTYPE tiles-definitions PUBLIC
&&quot;-//Apache Software Foundation//DTD Tiles Configuration//EN&&quot;
@@ -308,13 +352,15 @@
</pre>
</div>
<div class="subsection1">
-<h3>Debugging</h3>
-<p>To debug a page made of Tiles, you can use following advices:</p>
-<ul>
- <li>Check each Tiles separatly. Try to access nested Tiles directly to test
- if thes work properly.</li>
- <li>Enable Tiles logging. See the commons-logging package help.</li>
-</ul>
+ <h3>Debugging</h3>
+
+ <p>To debug a page made of Tiles, you can use following advices:</p>
+ <ul>
+ <li>Check each Tiles separatly. Try to access nested Tiles directly to test
+ if thes work properly.
+ </li>
+ <li>Enable Tiles logging. See the commons-logging package help.</li>
+ </ul>
</div>
</div>
</div>
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java Wed Nov 1 18:03:00 2006
@@ -17,11 +17,10 @@
*/
package org.apache.tiles.preparer;
-import org.apache.tiles.ViewPreparer;
-import org.apache.tiles.TilesRequestContext;
-import org.apache.tiles.util.RequestUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.TilesRequestContext;
+import org.apache.tiles.util.RequestUtils;
import java.util.HashMap;
import java.util.Map;
@@ -34,7 +33,7 @@
public class BasicPreparerFactory implements PreparerFactory {
private static final Log LOG =
- LogFactory.getLog(BasicPreparerFactory.class);
+ LogFactory.getLog(BasicPreparerFactory.class);
private Map<String, ViewPreparer> preparers;
@@ -47,13 +46,13 @@
* Create a new instance of the named preparer. This factory
* expects all names to be qualified class names.
*
- * @param name the named preparer
+ * @param name the named preparer
* @param context
* @return
* @throws NoSuchPreparerException
*/
public ViewPreparer getPreparer(String name, TilesRequestContext context)
- throws NoSuchPreparerException {
+ throws NoSuchPreparerException {
if (!preparers.containsKey(name)) {
preparers.put(name, createPreparer(name));
@@ -85,7 +84,7 @@
} catch (java.lang.ClassCastException ex) {
throw new NoSuchPreparerException(
"ViewPreparer of class '" + name
- + "' should implements 'ViewPreparer' or extends 'Action'");
+ + "' should implements 'ViewPreparer' or extends 'Action'");
} catch (InstantiationException e) {
throw new NoSuchPreparerException(
"Error - Unable to instantiate ViewPreparer '"
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java Wed Nov 1 18:03:00 2006
@@ -20,8 +20,8 @@
/**
* Thrown when the named preparer can not be found.
*
- * @since 2.0
* @version $Id$
+ * @since 2.0
*/
public class NoSuchPreparerException extends PreparerException {
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java Wed Nov 1 18:03:00 2006
@@ -17,27 +17,26 @@
*/
package org.apache.tiles.preparer;
-import org.apache.tiles.ViewPreparer;
import org.apache.tiles.TilesRequestContext;
/**
* Factory interface used to create/retrieve instances of
* the {@link ViewPreparer} interface.
- *
+ * <p/>
* This factory provides an extension point into the default
* tiles implementation. Implementors wishing to provide
* per request initialization of the ViewPreparer (for instance)
* may provide a custom prerparer.
*
- * @since 2.0
* @verion $Id$
+ * @since 2.0
*/
public interface PreparerFactory {
/**
* Create the named {link ViewPreparer} for the specified context.
*
- * @param name ViewPreparer name, commonly the qualified classname.
+ * @param name ViewPreparer name, commonly the qualified classname.
* @param context the context within which the preparer will be invoked.
* @return instance of the ViewPreparer
* @throws NoSuchPreparerException when the named preparer can not be found.
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/UrlViewPreparer.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/UrlViewPreparer.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/UrlViewPreparer.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java Wed Nov 1 18:03:00 2006
@@ -16,35 +16,37 @@
* limitations under the License.
*/
-package org.apache.tiles;
+package org.apache.tiles.preparer;
-import java.io.IOException;
+import org.apache.tiles.ComponentContext;
+import org.apache.tiles.TilesRequestContext;
/**
* Tiles preparer including a local URL.
*/
public class UrlViewPreparer implements ViewPreparer {
- /**
- * URL associated with this preparer.
+ /**
+ * URL associated with this preparer.
*/
protected String url = null;
/**
* Constructor.
+ *
* @param url URL.
*/
public UrlViewPreparer(String url) {
- this.url = url;
+ this.url = url;
}
/**
- * @see org.apache.tiles.ViewPreparer#execute(org.apache.tiles.TilesRequestContext, org.apache.tiles.ComponentContext)
+ * @see ViewPreparer#execute(org.apache.tiles.TilesRequestContext,org.apache.tiles.ComponentContext)
*/
public void execute(TilesRequestContext tilesContext,
- ComponentContext componentContext)
- throws Exception {
-
+ ComponentContext componentContext)
+ throws Exception {
+
tilesContext.include(url);
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ViewPreparer.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ViewPreparer.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ViewPreparer.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java Wed Nov 1 18:03:00 2006
@@ -16,23 +16,27 @@
* limitations under the License.
*/
-package org.apache.tiles;
+package org.apache.tiles.preparer;
+
+import org.apache.tiles.ComponentContext;
+import org.apache.tiles.TilesRequestContext;
/**
* A preparer is a piece of code called before rendering a jsp page.
- * A preparer can be associated to a tile. See <insert> or
+ * A preparer can be associated to a tile. See <insert> or
* <definition> for association syntax.
*/
public interface ViewPreparer {
/**
- * Method associated to a tile and called immediately before the tile
+ * Method associated to a tile and called immediately before the tile
* is included.
- * @param tilesContext Current tiles application context.
+ *
+ * @param tilesContext Current tiles application context.
* @param componentContext Current tile context.
*/
public void execute(
- TilesRequestContext tilesContext,
- ComponentContext componentContext)
- throws Exception;
+ TilesRequestContext tilesContext,
+ ComponentContext componentContext)
+ throws Exception;
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ViewPreparerSupport.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ViewPreparerSupport.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ViewPreparerSupport.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java Wed Nov 1 18:03:00 2006
@@ -16,13 +16,14 @@
* limitations under the License.
*/
-package org.apache.tiles;
+package org.apache.tiles.preparer;
-import java.io.IOException;
+import org.apache.tiles.ComponentContext;
+import org.apache.tiles.TilesRequestContext;
/**
* Basic implementation of ViewPreparer. Implementations can extend this class
- * to insulate themselves from changes in the <code>ViewPreparer</code>
+ * to insulate themselves from changes in the <code>ViewPreparer</code>
* interface.
*/
public class ViewPreparerSupport implements ViewPreparer {
@@ -30,7 +31,7 @@
/**
* Stubs out preparer method.
*/
- public void execute(TilesRequestContext tilesContext,
- ComponentContext componentContext) throws Exception {
+ public void execute(TilesRequestContext tilesContext,
+ ComponentContext componentContext) throws Exception {
}
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java Wed Nov 1 18:03:00 2006
@@ -18,20 +18,28 @@
package org.apache.tiles.servlet;
-import java.util.Enumeration;
-import java.util.Map;
-
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-import java.util.HashMap;
-
-import org.apache.tiles.*;
-import org.apache.tiles.access.TilesAccess;
-import org.apache.tiles.context.TilesContextFactory;
-import org.apache.tiles.context.BasicTilesContextFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.context.BasicTilesContextFactory;
+import org.apache.tiles.context.TilesContextFactory;
+import org.apache.tiles.definition.DefinitionsFactory;
+import org.apache.tiles.definition.DefinitionsFactoryConfig;
+import org.apache.tiles.definition.DefinitionsFactoryException;
+import org.apache.tiles.util.DefinitionsUtil;
+import org.apache.tiles.util.TilesUtil;
+import org.apache.tiles.util.TilesUtilImpl;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpServlet;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
/**
* This is the entry point for Tiles. The <code>TilesServlet</code> initializes
@@ -137,7 +145,7 @@
* An error message stating that something went wrong during initialization
*/
private static final String CANT_POPULATE_FACTORY_ERROR =
- "CAN'T POPULATE TILES DEFINITION FACTORY";
+ "CAN'T POPULATE TILES DEFINITION FACTORY";
/**
@@ -161,7 +169,7 @@
* @param config The servlet config
*/
public void init(ServletConfig config)
- throws javax.servlet.ServletException {
+ throws javax.servlet.ServletException {
super.init(config);
LOG.info("Initializing TilesServlet");
configFiles = config.getInitParameter("definitions-config");
@@ -195,7 +203,7 @@
* file is <code>/WEB-INF/tiles.xml</code>.
*/
protected DefinitionsFactoryConfig readFactoryConfig(ServletConfig config)
- throws ServletException {
+ throws ServletException {
DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
Map map = new HashMap();
@@ -205,7 +213,7 @@
map.put(DEFAULT_CONFIG_FILE_PARAM, configFiles);
} else {
LOG.info("CONFIG FILES WERE NOT DEFINED IN WEB.XML, " +
- "LOOKING FOR " + DEFAULT_CONFIG_FILE);
+ "LOOKING FOR " + DEFAULT_CONFIG_FILE);
map.put(DEFAULT_CONFIG_FILE_PARAM, DEFAULT_CONFIG_FILE);
}
@@ -228,13 +236,13 @@
*/
private void initDefinitionsFactory(ServletContext servletContext,
DefinitionsFactoryConfig factoryConfig)
- throws ServletException {
+ throws ServletException {
LOG.info("initializing definitions impl...");
// Create configurable impl
try {
definitionFactory = DefinitionsUtil.createDefinitionsFactory(
- factoryConfig);
+ factoryConfig);
} catch (DefinitionsFactoryException ex) {
ex.printStackTrace();
throw new ServletException(ex.getMessage(), ex);
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTag.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTag.java Wed Nov 1 18:03:00 2006
@@ -21,47 +21,45 @@
import javax.servlet.jsp.JspException;
- /**
- * Add an element to the surrounding list tag.
- * Same syntax as <code><put></code>.
- */
+/**
+ * Add an element to the surrounding list tag.
+ * Same syntax as <code><put></code>.
+ */
public class AddTag extends PutTag {
- /**
- * default constructor
- */
- public AddTag() {
- super();
- }
+ /**
+ * default constructor
+ */
+ public AddTag() {
+ super();
+ }
/**
* Call parent tag which must implement AttributeContainer.
+ *
* @throws JspException If we can't find an appropriate enclosing tag.
*/
- protected void callParent() throws JspException
- {
- // Get enclosing parent
- AddTagParent enclosingParent = findEnclosingPutListTagParent();
- enclosingParent.processNestedTag( this );
+ protected void callParent() throws JspException {
+ // Get enclosing parent
+ AddTagParent enclosingParent = findEnclosingPutListTagParent();
+ enclosingParent.processNestedTag(this);
}
/**
* Find parent tag which must implement AttributeContainer.
+ *
* @throws JspException If we can't find an appropriate enclosing tag.
*/
- protected AddTagParent findEnclosingPutListTagParent() throws JspException {
- try
- {
- AddTagParent parent = (AddTagParent)findAncestorWithClass(this,AddTagParent.class);
- if( parent == null )
- {
- throw new JspException( "Error - tag add : enclosing tag doesn't accept 'add' tag." );
+ protected AddTagParent findEnclosingPutListTagParent() throws JspException {
+ try {
+ AddTagParent parent = (AddTagParent) findAncestorWithClass(this, AddTagParent.class);
+ if (parent == null) {
+ throw new JspException("Error - tag add : enclosing tag doesn't accept 'add' tag.");
+ }
+ return parent;
}
- return parent;
- }
- catch( ClassCastException ex )
- {
- throw new JspException( "Error - tag add : enclosing tag doesn't accept 'add' tag." , ex);
+ catch (ClassCastException ex) {
+ throw new JspException("Error - tag add : enclosing tag doesn't accept 'add' tag." , ex);
}
}
}
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTagParent.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTagParent.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTagParent.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTagParent.java Wed Nov 1 18:03:00 2006
@@ -28,6 +28,7 @@
public interface AddTagParent {
/**
* Process the nested tag.
+ *
* @param nestedTag Nested to process.
*/
void processNestedTag(AddTag nestedTag) throws JspException;
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java Wed Nov 1 18:03:00 2006
@@ -18,41 +18,41 @@
package org.apache.tiles.taglib;
-import javax.servlet.jsp.JspException;
-
-import org.apache.tiles.ComponentAttribute;
+import org.apache.tiles.definition.ComponentAttribute;
import org.apache.tiles.ComponentContext;
-import org.apache.tiles.ComponentDefinition;
+import org.apache.tiles.definition.ComponentDefinition;
import org.apache.tiles.taglib.util.TagUtils;
+import javax.servlet.jsp.JspException;
+
/**
* This is the tag handler for <tiles:attribute>, which defines an
* attribute. If the attribute value is a template or a definition, its
* attributes and its template can be overridden.
- *
+ *
* @version $Rev$ $Date$
*/
public class AttributeTag extends BaseInsertTag {
-
+
/**
* Name to insert.
*/
protected String name = null;
-
+
/**
* Set name.
*/
public void setName(String value) {
this.name = value;
}
-
+
/**
* Get name.
*/
public String getName() {
return name;
}
-
+
/**
* Processes tag attributes and create corresponding tag handler.<br>
* This implementation processes the attribute name to create an
@@ -62,103 +62,103 @@
public TagHandler createTagHandler() throws JspException {
return processAttribute(name);
}
-
+
/**
* Reset member values for reuse. This method calls super.release(), which
* invokes TagSupport.release(), which typically does nothing.
*/
public void release() {
-
+
super.release();
-
+
flush = true;
name = null;
template = null;
role = null;
isErrorIgnored = false;
-
+
releaseInternal();
}
-
+
/**
* Process tag attribute "attribute". Get value from component attribute.
* Found value is process by processObjectValue().
- *
+ *
* @param name Name of the attribute.
* @return Appropriate TagHandler.
* @throws JspException - NoSuchDefinitionException No Definition found for
- * name.
+ * name.
* @throws JspException - Throws by underlying nested call to
- * processDefinitionName()
+ * processDefinitionName()
*/
public TagHandler processAttribute(String name) throws JspException {
Object attrValue = null;
ComponentContext context = getCurrentContext();
-
+
if (context != null) {
attrValue = context.getAttribute(name);
}
-
+
if (attrValue == null) {
throw new JspException(
- "Error - Tag Insert : No value found for attribute '"
- + name + "'.");
+ "Error - Tag Insert : No value found for attribute '"
+ + name + "'.");
} else if (attrValue instanceof ComponentAttribute) {
return processTypedAttribute((ComponentAttribute) attrValue);
} else {
throw new JspException("Invalid attribute type: "
- + attrValue.getClass().getName());
+ + attrValue.getClass().getName());
}
}
-
+
/**
* Process typed attribute explicitly according to its type.
- *
+ *
* @param value Typed attribute to process.
* @return appropriate TagHandler.
* @throws JspException - Throws by underlying nested call to
- * processDefinitionName()
+ * processDefinitionName()
*/
public TagHandler processTypedAttribute(ComponentAttribute value)
- throws JspException {
-
+ throws JspException {
+
if (value == null) {
// FIXME.
return null;
}
-
+
// FIXME Currently this call executes with every attribute, even
// those that do not need to be preprocessed, like attributes from
// Tiles definitions files. Fix it to improve performances.
preprocessAttribute(value);
String type = value.getType();
-
+
if (type == null) {
throw new JspException("Unrecognized type for attribute value "
- + value.getValue());
+ + value.getValue());
}
-
+
if (type.equalsIgnoreCase("string")) {
return new DirectStringHandler((String) value.getValue());
} else if (type.equalsIgnoreCase("definition")) {
return processDefinition((ComponentDefinition) value.getValue());
} else {
return new InsertHandler((String) value.getValue(), role,
- getPreparer());
+ getPreparer());
}
}
-
+
/**
* Preprocess an attribute before using it. It guesses the type of the
* attribute if it is missing, and gets the right definition if a definition
* name has been specified.
- *
+ *
* @param value The attribute to preprocess.
* @throws JspException If something goes wrong during definition
- * resolution.
+ * resolution.
*/
protected void preprocessAttribute(ComponentAttribute value)
- throws JspException {
+ throws JspException {
String type = value.getType();
if (type == null) {
Object valueContent = value.getValue();
@@ -168,7 +168,7 @@
type = "template";
} else {
ComponentDefinition definition = TagUtils
- .getComponentDefinition(valueString, pageContext);
+ .getComponentDefinition(valueString, pageContext);
if (definition != null) {
type = "definition";
value.setValue(definition);
@@ -181,18 +181,18 @@
}
if (type == null) {
throw new JspException("Unrecognized type for attribute value "
- + value.getValue());
+ + value.getValue());
}
value.setType(type);
} else if (type.equalsIgnoreCase("definition")) {
Object valueContent = value.getValue();
if (valueContent instanceof String) {
ComponentDefinition definition = TagUtils
- .getComponentDefinition((String) valueContent,
- pageContext);
+ .getComponentDefinition((String) valueContent,
+ pageContext);
if (definition == null) {
throw new JspException("Cannot find any definition named '"
- + valueContent + "'");
+ + valueContent + "'");
}
value.setValue(definition);
}