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 2009/03/17 23:39:02 UTC

svn commit: r755432 - /tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/

Author: apetrelli
Date: Tue Mar 17 22:39:01 2009
New Revision: 755432

URL: http://svn.apache.org/viewvc?rev=755432&view=rev
Log:
TILES-381
Added Javadocs for tiles-template.

Modified:
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AttributeResolver.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ComposeStackUtil.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefaultAttributeResolver.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ImportAttributeModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/NoSuchAttributeException.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java
    tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java Tue Mar 17 22:39:01 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.util.Stack;
@@ -5,13 +26,49 @@
 import org.apache.tiles.Attribute;
 import org.apache.tiles.ListAttribute;
 
+/**
+ * <p>
+ * <strong>Add an element to the surrounding list. Equivalent to 'putAttribute',
+ * but for list element.</strong>
+ * </p>
+ * 
+ * <p>
+ * Add an element to the surrounding list. This tag can only be used inside
+ * 'putListAttribute' or 'addListAttribute' tags. Value can come from a direct
+ * assignment (value="aValue")
+ * </p>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class AddAttributeModel {
 
+    /**
+     * Starts the operation..
+     * 
+     * @param composeStack The composing stack.
+     * @since 2.2.0
+     */
     public void start(Stack<Object> composeStack) {
         Attribute attribute = new Attribute();
         composeStack.push(attribute);
     }
-    
+
+    /**
+     * Ends the operation.
+     * 
+     * @param composeStack The composing stack.
+     * @param value The value of the attribute. Use this parameter, or
+     * expression, or body.
+     * @param expression The expression to calculate the value from. Use this
+     * parameter, or value, or body.
+     * @param body The body of the tag. Use this parameter, or value, or
+     * expression.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param type The type (renderer) of the attribute.
+     * @since 2.2.0
+     */
     public void end(Stack<Object> composeStack, Object value,
             String expression, String body, String role, String type) {
         Attribute attribute = (Attribute) composeStack.pop();
@@ -19,18 +76,49 @@
                 role, type);
     }
 
+    /**
+     * Executes the operation.
+     * 
+     * @param composeStack The composing stack.
+     * @param value The value of the attribute. Use this parameter, or
+     * expression, or body.
+     * @param expression The expression to calculate the value from. Use this
+     * parameter, or value, or body.
+     * @param body The body of the tag. Use this parameter, or value, or
+     * expression.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param type The type (renderer) of the attribute.
+     * @since 2.2.0
+     */
     public void execute(Stack<Object> composeStack, Object value,
             String expression, String body, String role, String type) {
         addAttributeToList(new Attribute(), composeStack, value, expression,
                 body, role, type);
     }
-    
+
+    /**
+     * Adds the attribute to the containing list attribute.
+     * 
+     * @param attribute The attribute to add to the list attribute.
+     * @param composeStack The composing stack.
+     * @param value The value of the attribute. Use this parameter, or
+     * expression, or body.
+     * @param expression The expression to calculate the value from. Use this
+     * parameter, or value, or body.
+     * @param body The body of the tag. Use this parameter, or value, or
+     * expression.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param type The type (renderer) of the attribute.
+     * @since 2.2.0
+     */
     private void addAttributeToList(Attribute attribute,
             Stack<Object> composeStack, Object value, String expression,
             String body, String role, String type) {
         ListAttribute listAttribute = (ListAttribute) ComposeStackUtil
                 .findAncestorWithClass(composeStack, ListAttribute.class);
-        if(value != null) {
+        if (value != null) {
             attribute.setValue(value);
         } else if (attribute.getValue() == null && body != null) {
             attribute.setValue(body);

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java Tue Mar 17 22:39:01 2009
@@ -1,17 +1,66 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.util.Stack;
 
 import org.apache.tiles.ListAttribute;
 
+/**
+ * <p>
+ * <strong>Declare a list that will be pass as an attribute. </strong>
+ * </p>
+ * <p>
+ * Declare a list that will be pass as an attribute . List elements are added
+ * using the tag 'addAttribute' or 'addListAttribute'. This tag can only be used
+ * inside 'insertTemplate', 'insertDefinition' or 'definition' tag.
+ * </p>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class AddListAttributeModel {
 
+    /**
+     * Starts the operation.
+     *
+     * @param composeStack The composing stack.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @since 2.2.0
+     */
     public void start(Stack<Object> composeStack, String role) {
         ListAttribute listAttribute = new ListAttribute();
         listAttribute.setRole(role);
         composeStack.push(listAttribute);
     }
-    
+
+    /**
+     * Ends the operation.
+     * 
+     * @param composeStack The composing stack.
+     * @return The composed list attributes.
+     * @since 2.2.0
+     */
     public ListAttribute end(Stack<Object> composeStack) {
         return (ListAttribute) composeStack.pop();
     }

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AttributeResolver.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AttributeResolver.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AttributeResolver.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/AttributeResolver.java Tue Mar 17 22:39:01 2009
@@ -1,9 +1,53 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import org.apache.tiles.Attribute;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * Resolves an attribute, depending on the given parameters.
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public interface AttributeResolver {
+
+    /**
+     * Computes the attribute.
+     * 
+     * @param container The Tiles container to use.
+     * @param attribute The attribute to return immediately, if not null.
+     * @param name The name of the attribute.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param ignore If <code>true</code> if the computed attribute is null, this problem will be ignored.
+     * @param defaultValue The default value of the attribute. To use only if the attribute was not computed.
+     * @param defaultValueRole The default comma-separated list of roles. To use only if the attribute was not computed.
+     * @param defaultValueType The default type of the attribute. To use only if the attribute was not computed.
+     * @param requestItems The request objects.
+     * @return The computed attribute.
+     * @since 2.2.0
+     */
     Attribute computeAttribute(TilesContainer container, Attribute attribute,
             String name, String role, boolean ignore,
             Object defaultValue, String defaultValueRole, String defaultValueType, Object... requestItems);

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ComposeStackUtil.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ComposeStackUtil.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ComposeStackUtil.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ComposeStackUtil.java Tue Mar 17 22:39:01 2009
@@ -1,13 +1,51 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.util.Stack;
 
+/**
+ * Utilities to work with compose stacks.
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class ComposeStackUtil {
 
+    /**
+     * Private constructor to avoid instantiation.
+     */
     private ComposeStackUtil() {
         
     }
 
+    /**
+     * Finds the first ancestor in the stack, that is assignable to the given class.
+     * 
+     * @param composeStack The compose stack to evaluate.
+     * @param clazz The class to check.
+     * @return The first ancestor that is assignable to the class, or null if not found.
+     * @since 2.2.0
+     */
     public static Object findAncestorWithClass(Stack<Object> composeStack, Class<?> clazz) {
         Object retValue = null;
         for (int i = composeStack.size() - 1; i >= 0 && retValue == null; i--) {

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefaultAttributeResolver.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefaultAttributeResolver.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefaultAttributeResolver.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefaultAttributeResolver.java Tue Mar 17 22:39:01 2009
@@ -1,17 +1,39 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import org.apache.tiles.Attribute;
 import org.apache.tiles.AttributeContext;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * The default implementation of AttributeResolver.
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class DefaultAttributeResolver implements AttributeResolver {
 
-    /**
-     * Computes the attribute to render, evaluating the various tag attributes.
-     * @param context The page context.
-     *
-     * @return The computed attribute.
-     */
+    /** {@inheritDoc} */
     public Attribute computeAttribute(TilesContainer container, Attribute attribute,
             String name, String role, boolean ignore,
             Object defaultValue, String defaultValueRole, String defaultValueType, Object... requestItems) {
@@ -38,6 +60,9 @@
     /**
      * Computes the default attribute.
      *
+     * @param defaultValue The default value of the attribute.
+     * @param defaultValueRole The default role of tha attribute.
+     * @param defaultValueType The default type of the attribute.
      * @return The default attribute.
      */
     private Attribute computeDefaultAttribute(Object defaultValue,

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java Tue Mar 17 22:39:01 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.util.Stack;
@@ -6,21 +27,68 @@
 import org.apache.tiles.Definition;
 import org.apache.tiles.mgmt.MutableTilesContainer;
 
+/**
+ * <p>
+ * <strong>Create a definition at runtime. </strong>
+ * </p>
+ * <p>
+ * Create a new definition at runtime. Newly created definition will be
+ * available across the entire request.
+ * </p>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class DefinitionModel {
 
+    /**
+     * Starts the operation.
+     * 
+     * @param composeStack The compose stack,
+     * @param name The name of the definition to create. If not specified, an anonymous definition will be created.
+     * @param template The template of this definition.
+     * @param role A comma-separated list of roles. If present, the definition
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param extendsParam The definition name that this definition extends.
+     * @param preparer The preparer to use to invoke before the definition is rendered.
+     * @since 2.2.0
+     */
     public void start(Stack<Object> composeStack, String name, String template,
             String role, String extendsParam, String preparer) {
         Definition definition = createDefinition(name, template, role,
                 extendsParam, preparer);
         composeStack.push(definition);
     }
-    
+
+    /**
+     * Ends the operation.
+     * 
+     * @param container The Tiles container to use. It must be "mutable".
+     * @param composeStack The compose stack.
+     * @param name The name of the definition to create. If not specified, an anonymous definition will be created.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void end(MutableTilesContainer container,
             Stack<Object> composeStack, String name, Object... requestItems) {
         Definition definition = (Definition) composeStack.pop();
         registerDefinition(definition, container, composeStack, requestItems);
     }
-    
+
+    /**
+     * Executes the operation.
+     * 
+     * @param container The Tiles container to use. It must be "mutable".
+     * @param composeStack The compose stack.
+     * @param name The name of the definition to create. If not specified, an anonymous definition will be created.
+     * @param template The template of this definition.
+     * @param role A comma-separated list of roles. If present, the definition
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param extendsParam The definition name that this definition extends.
+     * @param preparer The preparer to use to invoke before the definition is rendered.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void execute(MutableTilesContainer container,
             Stack<Object> composeStack, String name, String template,
             String role, String extendsParam, String preparer,
@@ -30,6 +98,17 @@
         registerDefinition(definition, container, composeStack, requestItems);
     }
 
+    /**
+     * Creates the definition to store.
+     * 
+     * @param name The name of the definition to create. If not specified, an anonymous definition will be created.
+     * @param template The template of this definition.
+     * @param role A comma-separated list of roles. If present, the definition
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param extendsParam The definition name that this definition extends.
+     * @param preparer The preparer to use to invoke before the definition is rendered.
+     * @return The created definition.
+     */
     private Definition createDefinition(String name, String template,
             String role, String extendsParam, String preparer) {
         Definition definition = new Definition();
@@ -43,15 +122,23 @@
         return definition;
     }
 
+    /**
+     * Registers a definition in the container.
+     * 
+     * @param definition The definition to register.
+     * @param container The container into which the definition will be registered. 
+     * @param composeStack The compose stack,
+     * @param requestItems The request object.
+     */
     private void registerDefinition(Definition definition,
             MutableTilesContainer container, Stack<Object> composeStack,
             Object... requestItems) {
         container.register(definition, requestItems);
-        
+
         if (composeStack.isEmpty()) {
             return;
         }
-        
+
         Object obj = composeStack.peek();
         if (obj instanceof Attribute) {
             Attribute attribute = (Attribute) obj;

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java Tue Mar 17 22:39:01 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.io.IOException;
@@ -9,16 +30,60 @@
 import org.apache.tiles.Attribute;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * <p>
+ * <strong> Render the value of the specified template attribute to the current
+ * Writer</strong>
+ * </p>
+ * 
+ * <p>
+ * Retrieve the value of the specified template attribute property, and render
+ * it to the current Writer as a String. The usual toString() conversions is
+ * applied on found value.
+ * </p>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class GetAsStringModel {
 
+    /**
+     * The logging object.
+     */
     private Log log = LogFactory.getLog(getClass());
-    
+
+    /**
+     * The attribute resolver to use.
+     */
     private AttributeResolver attributeResolver;
-    
+
+    /**
+     * Constructor.
+     * 
+     * @param attributeResolver The attribute resolver to use.
+     * @since 2.2.0
+     */
     public GetAsStringModel(AttributeResolver attributeResolver) {
         this.attributeResolver = attributeResolver;
     }
 
+    /**
+     * Starts the operation.
+     * 
+     * @param composeStack The compose stack,
+     * @param container The Tiles container to use.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param preparer The preparer to invoke before rendering the attribute.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param defaultValue The default value of the attribute. To use only if the attribute was not computed.
+     * @param defaultValueRole The default comma-separated list of roles. To use only if the attribute was not computed.
+     * @param defaultValueType The default type of the attribute. To use only if the attribute was not computed.
+     * @param name The name of the attribute.
+     * @param value The attribute to use immediately, if not null.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void start(Stack<Object> composeStack, TilesContainer container,
             boolean ignore, String preparer, String role, Object defaultValue,
             String defaultValueRole, String defaultValueType, String name,
@@ -28,7 +93,17 @@
                 value, requestItems);
         composeStack.push(attribute);
     }
-    
+
+    /**
+     * Ends the operation.
+     * 
+     * @param composeStack The compose stack,
+     * @param container The Tiles container to use.
+     * @param writer The writer into which the attribute will be written.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param requestItems The request objects.
+     * @throws IOException If an I/O error happens during rendering.
+     */
     public void end(Stack<Object> composeStack, TilesContainer container,
             Writer writer, boolean ignore, Object... requestItems)
             throws IOException {
@@ -36,6 +111,24 @@
         renderAttribute(attribute, container, writer, ignore, requestItems);
     }
 
+    /**
+     * Executes the operation.
+     * 
+     * @param container The Tiles container to use.
+     * @param writer The writer into which the attribute will be written.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param preparer The preparer to invoke before rendering the attribute.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param defaultValue The default value of the attribute. To use only if the attribute was not computed.
+     * @param defaultValueRole The default comma-separated list of roles. To use only if the attribute was not computed.
+     * @param defaultValueType The default type of the attribute. To use only if the attribute was not computed.
+     * @param name The name of the attribute.
+     * @param value The attribute to use immediately, if not null.
+     * @param requestItems The request objects.
+     * @throws IOException If an I/O error happens during rendering.
+     * @since 2.2.0
+     */
     public void execute(TilesContainer container, Writer writer,
             boolean ignore, String preparer, String role, Object defaultValue,
             String defaultValueRole, String defaultValueType, String name,
@@ -46,6 +139,22 @@
         renderAttribute(attribute, container, writer, ignore, requestItems);
     }
 
+    /**
+     * Resolves the attribute. and starts the context.
+     * 
+     * @param container The Tiles container to use.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param preparer The preparer to invoke before rendering the attribute.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param defaultValue The default value of the attribute. To use only if the attribute was not computed.
+     * @param defaultValueRole The default comma-separated list of roles. To use only if the attribute was not computed.
+     * @param defaultValueType The default type of the attribute. To use only if the attribute was not computed.
+     * @param name The name of the attribute.
+     * @param value The attribute to use immediately, if not null.
+     * @param requestItems The request objects.
+     * @return The resolved attribute.
+     */
     private Attribute resolveAttribute(TilesContainer container,
             boolean ignore, String preparer, String role, Object defaultValue,
             String defaultValueRole, String defaultValueType, String name,
@@ -54,12 +163,22 @@
             container.prepare(preparer, requestItems);
         }
         Attribute attribute = attributeResolver.computeAttribute(container,
-                value, name, role, ignore, defaultValue,
-                defaultValueRole, defaultValueType, requestItems);
+                value, name, role, ignore, defaultValue, defaultValueRole,
+                defaultValueType, requestItems);
         container.startContext(requestItems);
         return attribute;
     }
 
+    /**
+     * Renders the attribute as a string.
+     * 
+     * @param attribute The attribute to use, previously resolved. 
+     * @param container The Tiles container to use.
+     * @param writer The writer into which the attribute will be written.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param requestItems The request objects.
+     * @throws IOException If an I/O error happens during rendering.
+     */
     private void renderAttribute(Attribute attribute, TilesContainer container,
             Writer writer, boolean ignore, Object... requestItems)
             throws IOException {

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ImportAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ImportAttributeModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ImportAttributeModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/ImportAttributeModel.java Tue Mar 17 22:39:01 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.util.Collection;
@@ -10,16 +31,43 @@
 import org.apache.tiles.AttributeContext;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * <p>
+ * <strong>Import attribute(s) in specified context.</strong>
+ * </p>
+ * <p>
+ * Import attribute(s) to requested scope. Attribute name and scope are
+ * optional. If not specified, all attributes are imported in page scope. Once
+ * imported, an attribute can be used as any other beans from jsp contexts.
+ * </p>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class ImportAttributeModel {
 
+    /**
+     * The logging object.
+     */
     private Log log = LogFactory.getLog(getClass());
-    
+
+    /**
+     * Retuns a Map that contains the attributes to be imported. The importing code must be done by the caller.
+     * 
+     * @param container The Tiles container to use.
+     * @param name The attribute to import. If null, all the attributes will be imported.
+     * @param toName The destination name of the attribute to import. Valid only if <code>name</code> is specified.
+     * @param ignore If <code>true</code> and the attribute is not found, or an exception happens, the problem will be ignored.
+     * @param requestItems The request objects.
+     * @return A Map of the attributes to be imported: the key is the name of an attribute, the value is the value of that attribute.
+     * @since 2.2.0
+     */
     public Map<String, Object> getImportedAttributes(TilesContainer container,
             String name, String toName, boolean ignore, Object... requestItems) {
         Map<String, Object> retValue = new HashMap<String, Object>();
         AttributeContext attributeContext = container
                 .getAttributeContext(requestItems);
-        // Some tags allow for unspecified attributes.  This
+        // Some tags allow for unspecified attributes. This
         // implies that the tag should use all of the attributes.
         if (name != null) {
             importSingleAttribute(container, attributeContext, name, toName,
@@ -33,6 +81,17 @@
         return retValue;
     }
 
+    /**
+     * Imports a single attribute.
+     * 
+     * @param container The Tiles container to use.
+     * @param attributeContext The context from which the attributes will be got.
+     * @param name The name of the attribute.
+     * @param toName The name of the destination attribute. If null, <code>name</code> will be used.
+     * @param ignore If <code>true</code> and the attribute is not found, or an exception happens, the problem will be ignored.
+     * @param attributes The map of the attributes to fill.
+     * @param requestItems The request objects.
+     */
     private void importSingleAttribute(TilesContainer container,
             AttributeContext attributeContext, String name, String toName,
             boolean ignore, Map<String, Object> attributes,
@@ -48,7 +107,7 @@
         }
 
         Object attributeValue = null;
-        
+
         try {
             attributeValue = container.evaluate(attribute, requestItems);
         } catch (RuntimeException e) {
@@ -60,10 +119,10 @@
         }
 
         if (attributeValue == null && !ignore) {
-            throw new NoSuchAttributeException("Attribute with name '"
-                    + name + "' has a null value.");
+            throw new NoSuchAttributeException("Attribute with name '" + name
+                    + "' has a null value.");
         }
-        
+
         if (toName != null) {
             attributes.put(toName, attributeValue);
         } else {
@@ -72,10 +131,14 @@
     }
 
     /**
-     * Imports an attribute set.
-     *
+     * Imports all the attributes.
+     * 
      * @param names The names of the attributes to be imported.
-     * @throws TilesJspException If something goes wrong during the import.
+     * @param container The Tiles container to use.
+     * @param attributeContext The context from which the attributes will be got.
+     * @param attributes The map of the attributes to fill.
+     * @param ignore If <code>true</code> and the attribute is not found, or an exception happens, the problem will be ignored.
+     * @param requestItems The request objects.
      */
     private void importAttributes(Collection<String> names,
             TilesContainer container, AttributeContext attributeContext,
@@ -98,7 +161,8 @@
 
             if (attr != null) {
                 try {
-                    Object attributeValue = container.evaluate(attr, requestItems);
+                    Object attributeValue = container.evaluate(attr,
+                            requestItems);
                     if (attributeValue == null && !ignore) {
                         throw new NoSuchAttributeException(
                                 "Error importing attributes. " + "Attribute '"

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java Tue Mar 17 22:39:01 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.io.IOException;
@@ -8,16 +29,73 @@
 import org.apache.tiles.Attribute;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * <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>
+ * 
+ * <p>
+ * <strong>Example : </strong>
+ * </p>
+ * 
+ * <pre>
+ * &lt;code&gt;
+ *           &lt;tiles:insertAttribute name=&quot;body&quot; /&gt;
+ *         &lt;/code&gt;
+ * </pre>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class InsertAttributeModel {
 
+    /**
+     * The logging object.
+     */
     private Log log = LogFactory.getLog(getClass());
 
+    /**
+     * The attribute resolver to use.
+     */
     private AttributeResolver attributeResolver;
 
+    /**
+     * Constructor.
+     * 
+     * @param attributeResolver The attribute resolver to use.
+     * @since 2.2.0
+     */
     public InsertAttributeModel(AttributeResolver attributeResolver) {
         this.attributeResolver = attributeResolver;
     }
 
+    /**
+     * Starts the operation.
+     * 
+     * @param composeStack The compose stack,
+     * @param container The Tiles container to use.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param preparer The preparer to invoke before rendering the attribute.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param defaultValue The default value of the attribute. To use only if the attribute was not computed.
+     * @param defaultValueRole The default comma-separated list of roles. To use only if the attribute was not computed.
+     * @param defaultValueType The default type of the attribute. To use only if the attribute was not computed.
+     * @param name The name of the attribute.
+     * @param value The attribute to use immediately, if not null.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void start(Stack<Object> composeStack, TilesContainer container,
             boolean ignore, String preparer, String role, Object defaultValue,
             String defaultValueRole, String defaultValueType, String name,
@@ -28,14 +106,40 @@
         composeStack.push(attribute);
     }
 
+    /**
+     * Ends the operation.
+     * 
+     * @param composeStack The compose stack,
+     * @param container The Tiles container to use.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param requestItems The request objects.
+     * @throws IOException If an I/O error happens during rendering.
+     */
     public void end(Stack<Object> composeStack, TilesContainer container,
             boolean ignore, Object... requestItems) throws IOException {
         Attribute attribute = (Attribute) composeStack.pop();
         renderAttribute(container, ignore, attribute, requestItems);
     }
 
-    public void execute(TilesContainer container,
-            boolean ignore, String preparer, String role, Object defaultValue,
+    /**
+     * Executes the operation.
+     * 
+     * @param container The Tiles container to use.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param preparer The preparer to invoke before rendering the attribute.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param defaultValue The default value of the attribute. To use only if the attribute was not computed.
+     * @param defaultValueRole The default comma-separated list of roles. To use only if the attribute was not computed.
+     * @param defaultValueType The default type of the attribute. To use only if the attribute was not computed.
+     * @param name The name of the attribute.
+     * @param value The attribute to use immediately, if not null.
+     * @param requestItems The request objects.
+     * @throws IOException If an I/O error happens during rendering.
+     * @since 2.2.0
+     */
+    public void execute(TilesContainer container, boolean ignore,
+            String preparer, String role, Object defaultValue,
             String defaultValueRole, String defaultValueType, String name,
             Attribute value, Object... requestItems) throws IOException {
         Attribute attribute = resolveAttribute(container, ignore, preparer,
@@ -44,6 +148,22 @@
         renderAttribute(container, ignore, attribute, requestItems);
     }
 
+    /**
+     * Resolves the attribute. and starts the context.
+     * 
+     * @param container The Tiles container to use.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param preparer The preparer to invoke before rendering the attribute.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param defaultValue The default value of the attribute. To use only if the attribute was not computed.
+     * @param defaultValueRole The default comma-separated list of roles. To use only if the attribute was not computed.
+     * @param defaultValueType The default type of the attribute. To use only if the attribute was not computed.
+     * @param name The name of the attribute.
+     * @param value The attribute to use immediately, if not null.
+     * @param requestItems The request objects.
+     * @return The resolved attribute.
+     */
     private Attribute resolveAttribute(TilesContainer container,
             boolean ignore, String preparer, String role, Object defaultValue,
             String defaultValueRole, String defaultValueType, String name,
@@ -52,12 +172,21 @@
             container.prepare(preparer, requestItems);
         }
         Attribute attribute = attributeResolver.computeAttribute(container,
-                value, name, role, ignore, defaultValue,
-                defaultValueRole, defaultValueType, requestItems);
+                value, name, role, ignore, defaultValue, defaultValueRole,
+                defaultValueType, requestItems);
         container.startContext(requestItems);
         return attribute;
     }
 
+    /**
+     * Renders the attribute as a string.
+     * 
+     * @param attribute The attribute to use, previously resolved. 
+     * @param container The Tiles container to use.
+     * @param ignore If <code>true</code>, if an exception happens during rendering, of if the attribute is null, the problem will be ignored.
+     * @param requestItems The request objects.
+     * @throws IOException If an I/O error happens during rendering.
+     */
     private void renderAttribute(TilesContainer container, boolean ignore,
             Attribute attribute, Object... requestItems) throws IOException {
         try {

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java Tue Mar 17 22:39:01 2009
@@ -1,15 +1,94 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import org.apache.tiles.Attribute;
 import org.apache.tiles.AttributeContext;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * <p>
+ * <strong>Insert a definition.</strong>
+ * </p>
+ * <p>
+ * Insert a definition with the possibility to override and specify parameters
+ * (called attributes). A definition can be seen as a (partially or totally)
+ * filled template that can override or complete attribute values.
+ * <code>&lt;tiles:insertDefinition&gt;</code> allows to define these attributes
+ * and pass them to the inserted jsp page, called template. Attributes are
+ * defined using nested tag <code>&lt;tiles:putAttribute&gt;</code> or
+ * <code>&lt;tiles:putListAttribute&gt;</code>.
+ * </p>
+ * <p>
+ * You must specify <code>name</code> tag attribute, for inserting a definition
+ * from definitions factory.
+ * </p>
+ * <p>
+ * <strong>Example : </strong>
+ * </p>
+ * 
+ * <pre>
+ * &lt;code&gt;
+ *           &lt;tiles:insertDefinition name=&quot;.my.tiles.defininition flush=&quot;true&quot;&gt;
+ *              &lt;tiles:putAttribute name=&quot;title&quot; value=&quot;My first page&quot; /&gt;
+ *              &lt;tiles:putAttribute name=&quot;header&quot; value=&quot;/common/header.jsp&quot; /&gt;
+ *              &lt;tiles:putAttribute name=&quot;footer&quot; value=&quot;/common/footer.jsp&quot; /&gt;
+ *              &lt;tiles:putAttribute name=&quot;menu&quot; value=&quot;/basic/menu.jsp&quot; /&gt;
+ *              &lt;tiles:putAttribute name=&quot;body&quot; value=&quot;/basic/helloBody.jsp&quot; /&gt;
+ *           &lt;/tiles:insertDefinition&gt;
+ *         &lt;/code&gt;
+ * </pre>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class InsertDefinitionModel {
-    
+
+    /**
+     * Starts the operation.
+     * 
+     * @param container The Tiles container.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void start(TilesContainer container, Object... requestItems) {
         container.startContext(requestItems);
     }
 
+    /**
+     * Ends the operation.
+     * 
+     * @param container The Tiles container.
+     * @param definitionName The name of the definition to render.
+     * @param template If specified, this template will be used instead of the
+     * one used by the definition.
+     * @param role A comma-separated list of roles. If present, the definition
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param preparer The preparer to use to invoke before the definition is
+     * rendered. If specified, it overrides the preparer specified in the
+     * definition itself.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void end(TilesContainer container, String definitionName,
             String template, String role, String preparer,
             Object... requestItems) {
@@ -26,7 +105,22 @@
             container.endContext(requestItems);
         }
     }
-    
+
+    /**
+     * Executes the operation.
+     * 
+     * @param container The Tiles container.
+     * @param definitionName The name of the definition to render.
+     * @param template If specified, this template will be used instead of the
+     * one used by the definition.
+     * @param role A comma-separated list of roles. If present, the definition
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param preparer The preparer to use to invoke before the definition is
+     * rendered. If specified, it overrides the preparer specified in the
+     * definition itself.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void execute(TilesContainer container, String definitionName,
             String template, String role, String preparer,
             Object... requestItems) {

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java Tue Mar 17 22:39:01 2009
@@ -1,15 +1,92 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import org.apache.tiles.Attribute;
 import org.apache.tiles.AttributeContext;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * <p>
+ * <strong>Insert a template.</strong>
+ * </p>
+ * <p>
+ * Insert a template with the possibility to pass parameters (called
+ * attributes). A template can be seen as a procedure that can take parameters
+ * or attributes. <code>&lt;tiles:insertTemplate&gt;</code> allows to define
+ * these attributes and pass them to the inserted jsp page, called template.
+ * Attributes are defined using nested tag
+ * <code>&lt;tiles:putAttribute&gt;</code> or
+ * <code>&lt;tiles:putListAttribute&gt;</code>.
+ * </p>
+ * <p>
+ * You must specify <code>template</code> attribute, for inserting a template
+ * </p>
+ * 
+ * <p>
+ * <strong>Example : </strong>
+ * </p>
+ * 
+ * <pre>
+ * &lt;code&gt;
+ *           &lt;tiles:insertTemplate template=&quot;/basic/myLayout.jsp&quot; flush=&quot;true&quot;&gt;
+ *              &lt;tiles:putAttribute name=&quot;title&quot; value=&quot;My first page&quot; /&gt;
+ *              &lt;tiles:putAttribute name=&quot;header&quot; value=&quot;/common/header.jsp&quot; /&gt;
+ *              &lt;tiles:putAttribute name=&quot;footer&quot; value=&quot;/common/footer.jsp&quot; /&gt;
+ *              &lt;tiles:putAttribute name=&quot;menu&quot; value=&quot;/basic/menu.jsp&quot; /&gt;
+ *              &lt;tiles:putAttribute name=&quot;body&quot; value=&quot;/basic/helloBody.jsp&quot; /&gt;
+ *           &lt;/tiles:insertTemplate&gt;
+ *         &lt;/code&gt;
+ * </pre>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class InsertTemplateModel {
-    
+
+    /**
+     * Starts the operation.
+     * 
+     * @param container The Tiles container.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void start(TilesContainer container, Object... requestItems) {
         container.startContext(requestItems);
     }
 
+    /**
+     * Ends the operation.
+     * 
+     * @param container The Tiles container.
+     * @param template The template to render.
+     * @param role A comma-separated list of roles. If present, the template
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param preparer The preparer to use to invoke before the definition is
+     * rendered. If specified, it overrides the preparer specified in the
+     * definition itself.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void end(TilesContainer container, String template, String role,
             String preparer, Object... requestItems) {
         try {
@@ -26,6 +103,19 @@
         }
     }
 
+    /**
+     * Executes the operation.
+     * 
+     * @param container The Tiles container.
+     * @param template The template to render.
+     * @param role A comma-separated list of roles. If present, the template
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param preparer The preparer to use to invoke before the definition is
+     * rendered. If specified, it overrides the preparer specified in the
+     * definition itself.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void execute(TilesContainer container, String template, String role,
             String preparer, Object... requestItems) {
         start(container, requestItems);

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/NoSuchAttributeException.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/NoSuchAttributeException.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/NoSuchAttributeException.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/NoSuchAttributeException.java Tue Mar 17 22:39:01 2009
@@ -26,14 +26,14 @@
  * Indicates that a named attribute has not been found.
  *
  * @version $Rev$ $Date$
- * @since 2.1.0
+ * @since 2.2.0
  */
 public class NoSuchAttributeException extends TilesException {
 
     /**
      * Constructor.
      *
-     * @since 2.1.0
+     * @since 2.2.0
      */
     public NoSuchAttributeException() {
     }
@@ -42,7 +42,7 @@
      * Constructor.
      *
      * @param message The detail message.
-     * @since 2.1.0
+     * @since 2.2.0
      */
     public NoSuchAttributeException(String message) {
         super(message);
@@ -52,7 +52,7 @@
      * Constructor.
      *
      * @param e The exception to be wrapped.
-     * @since 2.1.0
+     * @since 2.2.0
      */
     public NoSuchAttributeException(Exception e) {
         super(e);
@@ -63,7 +63,7 @@
      *
      * @param message The detail message.
      * @param e The exception to be wrapped.
-     * @since 2.1.0
+     * @since 2.2.0
      */
     public NoSuchAttributeException(String message, Exception e) {
         super(message, e);

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java Tue Mar 17 22:39:01 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.util.Stack;
@@ -6,13 +27,74 @@
 import org.apache.tiles.AttributeContext;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * <p>
+ * <strong>Put an attribute in enclosing attribute container tag.</strong>
+ * </p>
+ * <p>
+ * Enclosing attribute container tag can be :
+ * <ul>
+ * <li>&lt;initContainer&gt;</li>
+ * <li>&lt;definition&gt;</li>
+ * <li>&lt;insertAttribute&gt;</li>
+ * <li>&lt;insertDefinition&gt;</li>
+ * <li>&lt;putListAttribute&gt;</li>
+ * </ul>
+ * (or any other tag which implements the <code>PutAttributeTagParent</code>
+ * interface. Exception is thrown if no appropriate tag can be found.
+ * </p>
+ * <p>
+ * Put tag can have following atributes :
+ * <ul>
+ * <li>name : Name of the attribute</li>
+ * <li>value : value to put as attribute</li>
+ * <li>type : value type. Possible type are : string (value is used as direct
+ * string), template (value is used as a page url to insert), definition (value
+ * is used as a definition name to insert), object (value is used as it is)</li>
+ * <li>role : Role to check when 'insertAttribute' will be called.</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Value can also come from tag body. Tag body is taken into account only if
+ * value is not set by one of the tag attributes. In this case Attribute type is
+ * "string", unless tag body define another type.
+ * </p>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class PutAttributeModel {
 
+    /**
+     * Starts the operation.
+     * 
+     * @param composeStack The compose stack.
+     * @since 2.2.0
+     */
     public void start(Stack<Object> composeStack) {
         Attribute attribute = new Attribute();
         composeStack.push(attribute);
     }
-    
+
+    /**
+     * Ends the operation.
+     *
+     * @param container The Tiles container to use.
+     * @param composeStack The composing stack.
+     * @param name The name of the attribute to put.
+     * @param value The value of the attribute. Use this parameter, or
+     * expression, or body.
+     * @param expression The expression to calculate the value from. Use this
+     * parameter, or value, or body.
+     * @param body The body of the tag. Use this parameter, or value, or
+     * expression.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param type The type (renderer) of the attribute.
+     * @param cascade If <code>true</code> the attribute will be cascaded to all nested attributes.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void end(TilesContainer container, Stack<Object> composeStack,
             String name, Object value, String expression, String body,
             String role, String type, boolean cascade, Object... requestItems) {
@@ -21,13 +103,51 @@
                 expression, body, role, type, cascade, requestItems);
     }
 
+    /**
+     * Executes the operation.
+     *
+     * @param container The Tiles container to use.
+     * @param composeStack The composing stack.
+     * @param name The name of the attribute to put.
+     * @param value The value of the attribute. Use this parameter, or
+     * expression, or body.
+     * @param expression The expression to calculate the value from. Use this
+     * parameter, or value, or body.
+     * @param body The body of the tag. Use this parameter, or value, or
+     * expression.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param type The type (renderer) of the attribute.
+     * @param cascade If <code>true</code> the attribute will be cascaded to all nested attributes.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
     public void execute(TilesContainer container, Stack<Object> composeStack,
             String name, Object value, String expression, String body,
             String role, String type, boolean cascade, Object... requestItems) {
         putAttributeInParent(new Attribute(), container, composeStack, name,
                 value, expression, body, role, type, cascade, requestItems);
     }
-    
+
+    /**
+     * Determines the parent and puts the attribute inside it.
+     * 
+     * @param attribute The attribute to put;
+     * @param container The Tiles container to use.
+     * @param composeStack The composing stack.
+     * @param name The name of the attribute to put.
+     * @param value The value of the attribute. Use this parameter, or
+     * expression, or body.
+     * @param expression The expression to calculate the value from. Use this
+     * parameter, or value, or body.
+     * @param body The body of the tag. Use this parameter, or value, or
+     * expression.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param type The type (renderer) of the attribute.
+     * @param cascade If <code>true</code> the attribute will be cascaded to all nested attributes.
+     * @param requestItems The request objects.
+     */
     private void putAttributeInParent(Attribute attribute,
             TilesContainer container, Stack<Object> composeStack, String name,
             Object value, String expression, String body, String role,
@@ -42,7 +162,7 @@
         if (attributeContext == null) {
             attributeContext = container.getAttributeContext(requestItems);
         }
-        if(value != null) {
+        if (value != null) {
             attribute.setValue(value);
         } else if (attribute.getValue() == null && body != null) {
             attribute.setValue(body);

Modified: tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java?rev=755432&r1=755431&r2=755432&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java (original)
+++ tiles/framework/trunk/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java Tue Mar 17 22:39:01 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tiles.template;
 
 import java.util.Stack;
@@ -7,17 +28,49 @@
 import org.apache.tiles.ListAttribute;
 import org.apache.tiles.TilesContainer;
 
+/**
+ * <p>
+ * <strong>Declare a list that will be pass as attribute to tile. </strong>
+ * </p>
+ * <p>
+ * Declare a list that will be pass as attribute to tile. List elements are
+ * added using the tags 'addAttribute' or 'addListAttribute'. This tag can only
+ * be used inside 'insertTemplate', 'insertDefinition', 'definition' tags.
+ * </p>
+ * 
+ * @version $Rev$ $Date$
+ * @since 2.2.0
+ */
 public class PutListAttributeModel {
 
+    /**
+     * Starts the operation.
+     *
+     * @param composeStack The composing stack.
+     * @param role A comma-separated list of roles. If present, the attribute
+     * will be rendered only if the current user belongs to one of the roles.
+     * @param inherit If <code>true</code> the list contained in the in the same attribute of the parent definition will be extended.
+     * @since 2.2.0
+     */
     public void start(Stack<Object> composeStack, String role, boolean inherit) {
         ListAttribute listAttribute = new ListAttribute();
         listAttribute.setRole(role);
         listAttribute.setInherit(inherit);
         composeStack.push(listAttribute);
     }
-    
-    public void end(TilesContainer container,
-            Stack<Object> composeStack, String name, boolean cascade, Object... requestItems) {
+
+    /**
+     * Ends the operation.
+     * 
+     * @param container The Tiles container to use.
+     * @param composeStack The composing stack.
+     * @param name The name of the attribute to put.
+     * @param cascade If <code>true</code> the attribute will be cascaded to all nested attributes.
+     * @param requestItems The request objects.
+     * @since 2.2.0
+     */
+    public void end(TilesContainer container, Stack<Object> composeStack,
+            String name, boolean cascade, Object... requestItems) {
         ListAttribute listAttribute = (ListAttribute) composeStack.pop();
         AttributeContext attributeContext = null;
         if (!composeStack.isEmpty()) {