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/05 17:45:07 UTC
svn commit: r471458 - in /struts/sandbox/trunk/tiles:
tiles-api/src/main/java/org/apache/tiles/
tiles-core/src/main/java/org/apache/tiles/context/
tiles-core/src/main/java/org/apache/tiles/definition/
tiles-core/src/main/java/org/apache/tiles/taglib/ t...
Author: ddewolf
Date: Sun Nov 5 08:45:06 2006
New Revision: 471458
URL: http://svn.apache.org/viewvc?view=rev&rev=471458
Log:
simplifying taglibs
Added:
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTagSupport.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ContainerTagSupport.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTag.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTagParent.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/RenderTagSupport.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java (with props)
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java (contents, props changed)
- copied, changed from r470971, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTagSupport.java (contents, props changed)
- copied, changed from r470901, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/InitDefinitionsTag.java (contents, props changed)
- copied, changed from r470971, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java
struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/putallattributeslayout.jsp (with props)
struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testimportattribute_all.jsp (with props)
Removed:
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AddTagParent.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTagParent.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTei.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/util/
Modified:
struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java
struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentContext.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/BasicComponentContext.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java
struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld
struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/tiles-defs.xml
struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp
Modified: struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java (original)
+++ struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java Sun Nov 5 08:45:06 2006
@@ -29,8 +29,21 @@
* @version $Rev$ $Date$
*/
public class ComponentAttribute implements Serializable {
-
- public static final String DEFINITION_TYPE = "definition";
+
+ /**
+ * Attribute of type definition.
+ */
+ public static final String DEFINITION = "definition";
+
+ /**
+ * Attribute of type template.
+ */
+ public static final String TEMPLATE = "template";
+
+ /**
+ * Attribute of type string.
+ */
+ public static final String STRING = "string";
/**
* Role associated to this attribute.
Modified: struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentContext.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentContext.java?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentContext.java (original)
+++ struts/sandbox/trunk/tiles/tiles-api/src/main/java/org/apache/tiles/ComponentContext.java Sun Nov 5 08:45:06 2006
@@ -71,4 +71,9 @@
String beanName,
int scope,
PageContext pageContext);
+
+ /**
+ * Clear the attributes
+ */
+ void clear();
}
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/BasicComponentContext.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/BasicComponentContext.java?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/BasicComponentContext.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/context/BasicComponentContext.java Sun Nov 5 08:45:06 2006
@@ -223,4 +223,8 @@
tilesContext.getRequestScope().put(ComponentConstants.COMPONENT_CONTEXT, context);
}
+
+ public void clear() {
+ attributes.clear();
+ }
}
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java Sun Nov 5 08:45:06 2006
@@ -267,9 +267,9 @@
*/
public void put(String name, Object content, boolean direct, String role) {
if (direct) { // direct String
- put(name, content, "string", role);
+ put(name, content, ComponentAttribute.STRING, role);
} else {
- put(name, content, "template", role);
+ put(name, content, ComponentAttribute.TEMPLATE, role);
}
}
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=471458&r1=471457&r2=471458
==============================================================================
--- 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 Sun Nov 5 08:45:06 2006
@@ -20,12 +20,14 @@
package org.apache.tiles.taglib;
-import org.apache.tiles.context.BasicComponentContext;
+import org.apache.tiles.context.jsp.JspUtil;
import org.apache.tiles.ComponentAttribute;
-import org.apache.tiles.definition.ComponentDefinition;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.ComponentContext;
+import org.apache.tiles.taglib.RenderTagSupport;
import javax.servlet.jsp.JspException;
-import java.util.HashMap;
+import java.io.IOException;
import java.util.Map;
/**
@@ -35,165 +37,98 @@
*
* @version $Rev$ $Date$
*/
-public class AttributeTag extends BaseInsertTag {
+public class AttributeTag extends RenderTagSupport {
/**
* Name to insert.
*/
- protected String name = null;
+ protected String name;
+
+ protected String template;
- /**
- * 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
- * {@link InsertHandler} (if the attribute type is "definition" or
- * "template") or a {@link DirectStringHandler} (if the type is "string").
- */
- public TagHandler createTagHandler() throws JspException {
- return processAttribute(name);
+ public String getTemplate() {
+ return template;
}
- /**
- * 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();
+ public void setTemplate(String template) {
+ this.template = template;
}
- /**
- * 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.
- * @throws JspException - Throws by underlying nested call to
- * processDefinitionName()
- */
- public TagHandler processAttribute(String name) throws JspException {
- Object attrValue = null;
- BasicComponentContext context = getCurrentContext();
-
- if (context != null) {
- attrValue = context.getAttribute(name);
- }
- if (attrValue == null) {
- throw new JspException(
- "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());
- }
+ public void release() {
+ super.release();
+ this.name = null;
+ this.template = null;
}
- /**
- * 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()
- */
- public TagHandler processTypedAttribute(ComponentAttribute value)
- throws JspException {
-
- if (value == null) {
- // FIXME.
- return null;
+ protected void render() throws JspException, TilesException, IOException {
+ ComponentContext context = container.getComponentContext(pageContext);
+ ComponentAttribute attr = context.getAttribute(name);
+ if(attr == null && ignore) {
+ return;
}
- // 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());
+ if(attr == null) {
+ throw new TilesException("Attribute '"+name+"' not found.");
}
- if (type.equalsIgnoreCase("string")) {
- return new DirectStringHandler(value.getValue());
- } else if (type.equalsIgnoreCase("definition")) {
- Map<String, Object> attrs = new HashMap<String,Object>(value.getAttributes());
- return processDefinition((String) value.getValue(), attrs);
+ String type = calculateType(attr);
+ if("string".equalsIgnoreCase(type)) {
+ pageContext.getOut().print(attr.getValue());
+
+ } else if(isDefinition(attr)) {
+ if(template != null) {
+ attr.setValue(template);
+ }
+
+ Map<String, ComponentAttribute> attrs = attr.getAttributes();
+ if(attrs != null) {
+ for(Map.Entry<String, ComponentAttribute> a : attrs.entrySet()) {
+ context.putAttribute(a.getKey(), a.getValue());
+ }
+ }
+ container.render(pageContext, attr.getValue().toString());
+
} else {
- return new InsertHandler((String) value.getValue(), role,
- preparer);
+ JspUtil.doInclude(pageContext, attr.getValue().toString(), flush);
}
}
- /**
- * 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.
- */
- protected void preprocessAttribute(ComponentAttribute value)
- throws JspException {
- String type = value.getType();
+ private boolean isDefinition(ComponentAttribute attr) {
+ return ComponentAttribute.DEFINITION.equals(attr.getType()) ||
+ container.isValidDefinition(pageContext,
+ attr.getValue().toString());
+ }
+
+ private String calculateType(ComponentAttribute attr) throws JspException {
+ String type = attr.getType();
if (type == null) {
- Object valueContent = value.getValue();
+ Object valueContent = attr.getValue();
if (valueContent instanceof String) {
String valueString = (String) valueContent;
if (valueString.startsWith("/")) {
- type = "template";
+ type = ComponentAttribute.TEMPLATE;
} else {
if (container.isValidDefinition(pageContext, valueString)) {
- type = "definition";
- value.setValue(valueString);
+ type = ComponentAttribute.DEFINITION;
} else {
- type = "string";
+ type = ComponentAttribute.STRING;
}
}
- } else if (valueContent instanceof ComponentDefinition) {
- type = "definition";
}
if (type == null) {
throw new JspException("Unrecognized type for attribute value "
- + value.getValue());
- }
- value.setType(type);
- } else if (type.equalsIgnoreCase("definition")) {
- Object valueContent = value.getValue();
- if (valueContent instanceof String) {
- if (!container.isValidDefinition(pageContext, (String) valueContent))
- throw new JspException("Cannot find any definition named '"
- + valueContent + "'");
+ + attr.getValue());
}
- value.setValue(valueContent);
}
+ return type;
}
}
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTagSupport.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTagSupport.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTagSupport.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTagSupport.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,207 @@
+/*
+ * 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.taglib;
+
+import org.apache.tiles.ComponentAttribute;
+import org.apache.tiles.ComponentContext;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.access.TilesAccess;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.TagSupport;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Support for Scoped tags.
+ */
+public abstract class AttributeTagSupport extends TagSupport {
+
+
+ private static final Map<String, Integer> scopes =
+ new HashMap<String, Integer>();
+
+ static {
+ scopes.put("page", PageContext.PAGE_SCOPE);
+ scopes.put("request", PageContext.REQUEST_SCOPE);
+ scopes.put("session", PageContext.SESSION_SCOPE);
+ scopes.put("application", PageContext.APPLICATION_SCOPE);
+ }
+
+
+ protected String scopeName = null;
+
+ protected int scope = PageContext.PAGE_SCOPE;
+
+ protected String name = null;
+
+ protected boolean ignore = false;
+
+
+ protected TilesContainer container;
+
+ protected ComponentContext componentContext;
+
+ protected ComponentAttribute attribute;
+
+
+ /**
+ * Set the scope.
+ *
+ * @param scope Scope.
+ */
+ public void setScope(String scope) {
+ this.scopeName = scope;
+ }
+
+ /**
+ * Get scope.
+ *
+ * @return Scope.
+ */
+ public String getScope() {
+ return scopeName;
+ }
+
+ public void release() {
+ scopeName = null;
+ scope = PageContext.PAGE_SCOPE;
+ }
+
+ public int doStartTag() throws JspException {
+ container = TilesAccess.getContainer(pageContext.getServletContext());
+ componentContext = container.getComponentContext(pageContext);
+ scope = getScopeId();
+
+ // Some tags allow for unspecified attribues. This
+ // implies that the tag should use all of the attributes.
+ if (name != null) {
+ attribute = componentContext.getAttribute(name);
+ if ((attribute == null || attribute.getValue() == null) && ignore) {
+ return SKIP_BODY;
+ }
+
+ if (attribute == null) {
+ throw new JspException("Attribute whith name '" + name + "' + not found");
+ }
+
+ if (attribute.getValue() == null) {
+ throw new JspException("Attribute whith name '" + name + "' + has a null value.");
+ }
+ }
+
+ try {
+ execute();
+ } catch (IOException e) {
+ throw new JspException("io error while executing tag '" + getClass().getName() + "'.");
+ }
+
+ return SKIP_BODY;
+ }
+
+ public abstract void execute() throws JspException, IOException;
+
+ public int doEndTag() {
+ return EVAL_PAGE;
+ }
+
+ /**
+ * Get scope value from string value
+ *
+ * @return Scope as an <code>int</code>, or <code>defaultValue</code> if scope is <code>null</code>.
+ * @throws javax.servlet.jsp.JspException Scope name is not recognized as a valid scope.
+ */
+ public int getScopeId() throws JspException {
+ if (scopeName == null) {
+ return PageContext.PAGE_SCOPE;
+ }
+
+ if (scopeName.equalsIgnoreCase("component")) {
+ return ComponentConstants.COMPONENT_SCOPE;
+
+ } else if (scopeName.equalsIgnoreCase("template")) {
+ return ComponentConstants.COMPONENT_SCOPE;
+
+ } else if (scopeName.equalsIgnoreCase("tile")) {
+ return ComponentConstants.COMPONENT_SCOPE;
+
+ } else {
+ return getScope(scopeName);
+ }
+ }
+
+ /**
+ * Converts the scope name into its corresponding PageContext constant value.
+ *
+ * @param scopeName Can be "page", "request", "session", or "application" in any
+ * case.
+ * @return The constant representing the scope (ie. PageContext.REQUEST_SCOPE).
+ * @throws JspException if the scopeName is not a valid name.
+ */
+ public static int getScope(String scopeName) throws JspException {
+ Integer scope = scopes.get(scopeName.toLowerCase());
+
+ if (scope == null) {
+ throw new JspException("Unable to retrieve the scope " + scopeName);
+ }
+
+ return scope;
+ }
+
+ /**
+ * Get the name.
+ *
+ * @return Name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set the name.
+ *
+ * @param name The new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Set ignore flag.
+ *
+ * @param ignore default: <code>false</code>: Exception is thrown when attribute is not found, set to <code>
+ * true</code> to ignore missing attributes silently
+ */
+ public void setIgnore(boolean ignore) {
+ this.ignore = ignore;
+ }
+
+ /**
+ * Get ignore flag.
+ *
+ * @return default: <code>false</code>: Exception is thrown when attribute is not found, set to <code>
+ * true</code> to ignore missing attributes silently
+ */
+ public boolean getIgnore() {
+ return ignore;
+ }
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTagSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTagSupport.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ContainerTagSupport.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ContainerTagSupport.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ContainerTagSupport.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ContainerTagSupport.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,141 @@
+/*
+ * 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.taglib;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.ComponentContext;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.ComponentAttribute;
+import org.apache.tiles.access.TilesAccess;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.tagext.TryCatchFinally;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Base tag for the tiles tags which interact with the container.
+ * Provides standard support for security, and provides access
+ * to the container and component context.
+ * </p>
+ * This tag takes special care to ensure that the component context is
+ * reset to it's original state after the execution of the tag is
+ * complete. This ensures that all all included attributes in subsequent
+ * tiles are scoped properly and do not bleed outside their intended
+ * scope.
+ *
+ * @since Tiles 2.0
+ * @version $Rev$
+ *
+ */
+public abstract class ContainerTagSupport extends BodyTagSupport
+ implements TryCatchFinally {
+
+ /**
+ * The log instance for this tag.
+ */
+ private static final Log LOG = LogFactory.getLog(ContainerTagSupport.class);
+
+ private String role;
+ protected TilesContainer container;
+ protected ComponentContext componentContext;
+
+ private Map<String, ComponentAttribute> originalState;
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public int doStartTag() {
+ container = TilesAccess.getContainer(pageContext.getServletContext());
+ componentContext = container.getComponentContext(pageContext);
+ cacheState();
+ return isAccessAllowed() ? EVAL_BODY_BUFFERED : SKIP_BODY;
+ }
+
+ public int doEndTag() throws JspException {
+ if (isAccessAllowed()) {
+ try {
+ execute();
+ } catch (TilesException e) {
+ String message = "Error executing tag: " + e.getMessage();
+ LOG.error(message, e);
+ throw new JspException(message, e);
+ } catch (IOException io) {
+ String message = "IO Error executing tag: " + io.getMessage();
+ LOG.error(message, io);
+ throw new JspException(message, io);
+ }
+ }
+ return EVAL_PAGE;
+ }
+
+
+ public void doCatch(Throwable throwable) throws Throwable {
+ // noop;
+ }
+
+ public void doFinally() {
+ restoreState();
+ }
+
+ public void release() {
+ super.release();
+ this.role = null;
+ this.container = null;
+ this.componentContext = null;
+ originalState = null;
+ }
+
+ protected abstract void execute() throws TilesException, JspException, IOException;
+
+ protected boolean isAccessAllowed() {
+ HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
+ return (role == null || req.isUserInRole(role));
+ }
+
+ private void cacheState() {
+ originalState = new HashMap<String, ComponentAttribute>();
+ Iterator<String> i = componentContext.getAttributeNames();
+ while(i.hasNext()) {
+ String name = i.next();
+ ComponentAttribute original = componentContext.getAttribute(name);
+ ComponentAttribute a = new ComponentAttribute(
+ original.getValue(), original.getRole(), original.getType()
+ );
+ originalState.put(name, a);
+ }
+ }
+
+ private void restoreState() {
+ originalState.clear();
+ originalState.putAll(originalState);
+ }
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ContainerTagSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ContainerTagSupport.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,76 @@
+/*
+ * 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.taglib;
+
+import org.apache.tiles.taglib.AttributeTagSupport;
+import org.apache.tiles.taglib.ComponentConstants;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+
+/**
+ * Retrieve the value of the specified component/template attribute property,
+ * and render it to the current JspWriter as a String.
+ * The usual toString() conversion is applied on the found value.
+ */
+public class GetAsStringTag extends AttributeTagSupport implements ComponentConstants {
+
+ private String role = null;
+
+ public void release() {
+ super.release();
+ role = null;
+ }
+
+ /**
+ * Set role.
+ *
+ * @param role The role the user must be in to store content.
+ */
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ /**
+ * Get role.
+ *
+ * @return Role.
+ */
+ public String getRole() {
+ return role;
+ }
+
+ /**
+ * Print the attribute.
+ *
+ * @throws JspException On error processing tag.
+ * @throws IOException if io error occurs.
+ */
+ public void execute() throws JspException, IOException {
+ HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
+ if (role != null && !req.isUserInRole(role)) {
+ return;
+ }
+
+ pageContext.getOut().print(attribute.getValue().toString());
+
+ }
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/GetAsStringTag.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,73 @@
+/*
+ * 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.taglib;
+
+import org.apache.tiles.ComponentAttribute;
+import org.apache.tiles.taglib.AttributeTagSupport;
+
+import javax.servlet.jsp.JspException;
+import java.util.Iterator;
+
+
+/**
+ * Import attribute(s) into the specified scope.
+ * If not explicitly named, all attributes are imported.
+ * If the scope is not specified, page scope is assumed.
+ *
+ * @version $Rev$
+ * @since Tiles 1.0
+ */
+public class ImportAttributeTag extends AttributeTagSupport {
+
+
+ /**
+ * Expose the requested property from component context.
+ *
+ * @throws JspException On errors processing tag.
+ */
+ public void execute() throws JspException {
+ if (attribute != null) {
+ pageContext.setAttribute(name, attribute.getValue(), scope);
+ } else {
+ Iterator names = componentContext.getAttributeNames();
+ while (names.hasNext()) {
+ String name = (String) names.next();
+
+ if (name == null && !ignore) {
+ throw new JspException("Error importing attributes. " +
+ "Attribute with null key found.");
+ } else if (name == null) {
+ continue;
+ }
+
+ ComponentAttribute attr = componentContext.getAttribute(name);
+
+ if ( (attr == null || attr.getValue() == null) && !ignore) {
+ throw new JspException("Error importing attributes. "+
+ "Attribute '"+name+"' has a null value ");
+ } else if( attr == null || attr.getValue() == null) {
+ continue;
+ }
+
+ pageContext.setAttribute(name, attr.getValue(), scope);
+ }
+ }
+ }
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/ImportAttributeTag.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java Sun Nov 5 08:45:06 2006
@@ -20,96 +20,32 @@
package org.apache.tiles.taglib;
-import org.apache.tiles.definition.NoSuchDefinitionException;
+import org.apache.tiles.taglib.RenderTagSupport;
+import org.apache.tiles.TilesException;
import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
/**
* This is the tag handler for <tiles:insertDefinition>, which includes a
- * definition, eventually overriding or filling attributes of its template.
+ * name, eventually overriding or filling attributes of its template.
*
* @version $Rev$ $Date$
*/
-public class InsertDefinitionTag extends BaseInsertTag {
+public class InsertDefinitionTag extends RenderTagSupport {
+
+ private String name;
- /**
- * 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 definition name to create an
- * {@link InsertHandler} with its template page.
- */
- public TagHandler createTagHandler() throws JspException {
- return processDefinitionName(name);
+ public void setName(String name) {
+ this.name = 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 "definition". First, search definition in the
- * factory, then create handler from this definition.
- *
- * @return Appropriate TagHandler.
- * @throws JspException- NoSuchDefinitionException No Definition found for
- * name.
- * @throws JspException- FactoryNotFoundException Can't find Definitions
- * factory.
- * @throws JspException- DefinedComponentFactoryException General error in
- * factory.
- * @throws JspException InstantiationException Can't create requested
- * preparerInstance
- */
- protected TagHandler processDefinitionName(String definition) throws JspException {
-
- try {
-
- if (definition == null) { // is it possible ?
- throw new NoSuchDefinitionException(
- "Error - Tag Insert : Can't get definition '"
- + name
- + "'. Check if this name exists in definitions factory.");
- }
-
- return processDefinition(definition, null);
-
- } catch (NoSuchDefinitionException ex) {
- // Save exception to be able to show it later
- pageContext.setAttribute(ComponentConstants.EXCEPTION_KEY, ex,
- PageContext.REQUEST_SCOPE);
- throw new JspException(ex);
- }
+ protected void render() throws JspException, TilesException {
+ container.render(pageContext, name);
}
}
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java Sun Nov 5 08:45:06 2006
@@ -20,6 +20,10 @@
package org.apache.tiles.taglib;
+import org.apache.tiles.context.jsp.JspUtil;
+import org.apache.tiles.taglib.RenderTagSupport;
+import org.apache.tiles.taglib.PutTagParent;
+
import javax.servlet.jsp.JspException;
/**
@@ -28,23 +32,22 @@
*
* @version $Rev$ $Date$
*/
-public class InsertTemplateTag extends BaseInsertTag {
+public class InsertTemplateTag extends RenderTagSupport
+ implements PutTagParent {
+
+ private String template;
+
+ public String getTemplate() {
+ return template;
+ }
- /**
- * Processes tag attributes and create corresponding tag handler.<br>
- * This implementation processes the definition name to create an
- * {@link InsertHandler} with the specified template page.
- */
- public TagHandler createTagHandler() throws JspException {
- return processUrl(template);
+ public void setTemplate(String template) {
+ this.template = template;
}
- /**
- * Process the url.
- *
- * @throws JspException If failed to create preparerInstance
- */
- protected TagHandler processUrl(String url) throws JspException {
- return new InsertHandler(url, role, preparer);
+ protected void render() throws JspException {
+ JspUtil.doInclude(pageContext, template, flush);
}
+
+
}
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,84 @@
+/*
+ * 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.taglib;
+
+import org.apache.tiles.ComponentAttribute;
+import org.apache.tiles.taglib.PutTagParent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * PutList tag implementation.
+ *
+ * @version $Rev$
+ * @since Tiles 1.0
+ */
+public class PutListTag extends PutTag
+ implements PutTagParent {
+
+
+ public PutListTag() {
+ super.setValue(new ArrayList());
+ }
+
+ /**
+ * Get list defined in tag.
+ */
+ public List getValue() {
+ return (List) super.getValue();
+ }
+
+ public void setValue(Object object) {
+ throw new IllegalStateException("The value of the PutListTag must be the originally defined list.");
+ }
+
+ /**
+ * Release the state of this put list by
+ * clearing the contents of the list.
+ */
+ public void release() {
+ super.release();
+ getValue().clear();
+ }
+
+ /**
+ * Process nested ≶put> tag.
+ * <p/>
+ * Places the value of the nested tag within the
+ * {@link org.apache.tiles.ComponentContext}.It is the responsibility
+ * of the descendent to check security. Tags extending
+ * the {@link org.apache.tiles.taglib.ContainerTagSupport} will automatically provide
+ * the appropriate security.
+ *
+ * @param nestedTag the put tag desciendent.
+ */
+ public void processNestedTag(PutTag nestedTag) {
+ ComponentAttribute attribute = new ComponentAttribute(
+ nestedTag.getValue(), nestedTag.getRole(),
+ nestedTag.getType());
+
+ componentContext.putAttribute(
+ nestedTag.getName(),
+ attribute
+ );
+ }
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTag.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTag.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTag.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,143 @@
+/*
+ * 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.taglib;
+
+import org.apache.tiles.taglib.ContainerTagSupport;
+import org.apache.tiles.taglib.ComponentConstants;
+import org.apache.tiles.taglib.PutTagParent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+/**
+ * Put an attribute in enclosing attribute container tag.
+ * Enclosing attribute container tag can be : <insert> or <definition>.
+ * Exception is thrown if no appropriate tag can be found.
+ * Put tag can have following atributes :
+ * <li>
+ * <ul>name : Name of the attribute</ul>
+ * <ul>value : value to put as attribute</ul>
+ * <ul>type : value type. Only valid if value is a String and is set by
+ * value="something" or by a bean.
+ * 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)</ul>
+ * <ul>direct : Specify if value is to be used as a direct string or as a
+ * page url to insert. This is another way to specify the type. It only apply
+ * if value is set as a string, and type is not present.</ul>
+ * <ul>beanName : Name of a bean used for setting value. Only valid if value is not set.
+ * If property is specified, value come from bean's property. Otherwise, bean
+ * itself is used for value.</ul>
+ * <ul>beanProperty : Name of the property used for retrieving value.</ul>
+ * <ul>beanScope : Scope containing bean. </ul>
+ * <ul>role : Role to check when 'insert' will be called. If enclosing tag is
+ * <insert>, role is checked immediately. If enclosing tag is
+ * <definition>, role will be checked when this definition will be
+ * inserted.</ul>
+ * </li>
+ * 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.
+ */
+public class PutTag extends ContainerTagSupport implements ComponentConstants {
+
+ private static final Log LOG = LogFactory.getLog(PutTag.class);
+
+ /**
+ * Name of attribute to put in component context.
+ */
+ protected String name = null;
+
+ /**
+ * Associated attribute value.
+ */
+ private Object value = null;
+
+ /**
+ * Requested type for the value.
+ */
+ private String type = null;
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Release all allocated resources.
+ */
+ public void release() {
+ super.release();
+ name = null;
+ value = null;
+ type = null;
+ }
+
+ /**
+ * Save the body content of this tag (if any)
+ *
+ * @throws JspException if a JSP exception has occurred
+ */
+ public int doAfterBody() throws JspException {
+ if (bodyContent != null) {
+ value = bodyContent.getString();
+ type = "string";
+ }
+ return (SKIP_BODY);
+ }
+
+ protected void execute() throws JspException {
+ PutTagParent parent = (PutTagParent)
+ TagSupport.findAncestorWithClass(this, PutTagParent.class);
+
+
+ if (parent == null) {
+ String message = "Error: enclosing tag '"
+ +getParent().getClass().getName()+" doesn't accept 'put' tag.";
+ LOG.error(message);
+ throw new JspException(message);
+ }
+
+ parent.processNestedTag(this);
+ }
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTag.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTagParent.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTagParent.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTagParent.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTagParent.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,40 @@
+/*
+ * 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.taglib;
+
+import org.apache.tiles.taglib.PutTag;
+
+import javax.servlet.jsp.JspException;
+
+/**
+ * Tag classes implementing this interface can contain nested PutTag.
+ * This interface defines a method called by nested tags.
+ */
+public interface PutTagParent {
+ /**
+ * Process the nested tag.
+ *
+ * @param nestedTag Nested tag to process.
+ */
+ void processNestedTag(PutTag nestedTag) throws JspException;
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTagParent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/PutTagParent.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/RenderTagSupport.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/RenderTagSupport.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/RenderTagSupport.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/RenderTagSupport.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,125 @@
+/*
+ * 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.taglib;
+
+import org.apache.tiles.ComponentAttribute;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.taglib.PutTag;
+import org.apache.tiles.taglib.PutTagParent;
+
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+
+/**
+ * Support for all tags which render (a template, or definition).
+ * </p>
+ * Properly invokes the defined preparer and invokes the abstract
+ * render method upon completion.
+ *
+ * @version $Rev$
+ * @since Tiles 2.0
+ */
+public abstract class RenderTagSupport extends ContainerTagSupport
+ implements PutTagParent {
+
+ protected String preparer;
+ protected boolean flush;
+ protected boolean ignore;
+
+ public String getPreparer() {
+ return preparer;
+ }
+
+ public void setPreparer(String preparer) {
+ this.preparer = preparer;
+ }
+
+ public boolean isFlush() {
+ return flush;
+ }
+
+ public void setFlush(boolean flush) {
+ this.flush = flush;
+ }
+
+ public boolean isIgnore() {
+ return ignore;
+ }
+
+ public void setIgnore(boolean ignore) {
+ this.ignore = ignore;
+ }
+
+
+ public void release() {
+ preparer = null;
+ flush = false;
+ ignore = false;
+ super.release();
+ }
+
+ /**
+ * Execute the tag by invoking the preparer, if defined, and then
+ * rendering.
+ *
+ * @throws TilesException if a prepare or render exception occurs.
+ * @throws JspException if a jsp exception occurs.
+ * @throws IOException if an io exception occurs.
+ */
+ protected void execute() throws TilesException, JspException, IOException {
+ if (preparer != null) {
+ container.prepare(pageContext, preparer);
+ }
+ render();
+ }
+
+ /**
+ * Render the specified content.
+ *
+ * @throws TilesException if a prepare or render exception occurs.
+ * @throws JspException if a jsp exception occurs.
+ * @throws IOException if an io exception occurs.
+ */
+ protected abstract void render() throws JspException, TilesException, IOException;
+
+ /**
+ * Process nested ≶put> tag.
+ * <p/>
+ * Places the value of the nested tag within the
+ * {@link org.apache.tiles.ComponentContext}.It is the responsibility
+ * of the descendent to check security. Tags extending
+ * the {@link ContainerTagSupport} will automatically provide
+ * the appropriate security.
+ * </p>
+ *
+ * @param nestedTag the put tag desciendent.
+ */
+ public void processNestedTag(PutTag nestedTag) {
+ ComponentAttribute attribute = new ComponentAttribute(
+ nestedTag.getValue(), nestedTag.getRole(),
+ nestedTag.getType());
+
+ componentContext.putAttribute(
+ nestedTag.getName(),
+ attribute
+ );
+ }
+
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/RenderTagSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/RenderTagSupport.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java (added)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java Sun Nov 5 08:45:06 2006
@@ -0,0 +1,115 @@
+/*
+ * 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.taglib;
+
+import org.apache.tiles.taglib.AttributeTagSupport;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.VariableInfo;
+
+
+/**
+ * Exposes a component attribute as a scripting variable
+ * within the page.
+ *
+ * @version $Rev$
+ * @since Tiles 1.0
+ */
+public class UseAttributeTag extends AttributeTagSupport {
+
+ /**
+ * Class name of object.
+ */
+ private String classname = null;
+
+ /**
+ * Release all allocated resources.
+ */
+ public void release() {
+ super.release();
+ classname = null;
+ id = null;
+ }
+
+ /**
+ * Get class name.
+ *
+ * @return class name
+ */
+ public String getClassname() {
+ return classname;
+
+ }
+
+ /**
+ * Set the class name.
+ *
+ * @param name The new class name.
+ */
+ public void setClassname(String name) {
+ this.classname = name;
+ }
+
+
+ /**
+ * Expose the requested attribute from component context.
+ *
+ * @throws JspException if a JSP exception has occurred
+ */
+ public void execute() throws JspException {
+ pageContext.setAttribute(getScriptingVariable(), attribute.getValue(), scope);
+ }
+
+ public String getScriptingVariable() {
+ return id == null ? getName() : id;
+ }
+
+
+ /**
+ * Implementation of <code>TagExtraInfo</code> which identifies
+ * the scripting object(s) to be made visible.
+ */
+ public static class Tei extends TagExtraInfo {
+
+ /**
+ * Return information about the scripting variables to be created.
+ */
+ public VariableInfo[] getVariableInfo(TagData data) {
+ String classname = data.getAttributeString("classname");
+ if (classname == null) {
+ classname = "java.lang.Object";
+ }
+
+ String id = data.getAttributeString("id");
+ if (id == null) {
+ id = data.getAttributeString("name");
+ }
+
+ return new VariableInfo[] {
+ new VariableInfo(id, classname, true, VariableInfo.AT_END)
+ };
+
+ }
+ }
+}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/UseAttributeTag.java
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java (from r470971, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java?view=diff&rev=471458&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java&r1=470971&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java Sun Nov 5 08:45:06 2006
@@ -17,14 +17,17 @@
* under the License.
*
*/
+package org.apache.tiles.taglib.definition;
-package org.apache.tiles.taglib;
-
+import org.apache.tiles.taglib.PutTagParent;
+import org.apache.tiles.taglib.PutTag;
import org.apache.tiles.ComponentAttribute;
-import org.apache.tiles.definition.ComponentDefinition;
-import org.apache.tiles.taglib.util.TagUtils;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.access.TilesAccess;
import javax.servlet.jsp.JspException;
+import java.util.Map;
+import java.util.HashMap;
/**
* This is the tag handler for <tiles:definition>, which defines
@@ -33,9 +36,8 @@
*
* @version $Rev$ $Date$
*/
-public class DefinitionTag
- extends DefinitionTagSupport
- implements PutTagParent, PutListTagParent {
+public class DefinitionTag extends DefinitionTagSupport
+ implements PutTagParent {
/* JSP Tag attributes */
/**
@@ -53,199 +55,71 @@
*/
private String extendsDefinition = null;
- /* Internal properties */
- /**
- * Template definition
- */
- private ComponentDefinition definition = null;
-
- /**
- * Reset member values for reuse. This method calls super.release(),
- * which invokes TagSupport.release(), which typically does nothing.
- */
- public void release() {
- super.release();
- name = null;
- template = null;
- scope = null;
- role = null;
- extendsDefinition = null;
- }
-
- /**
- * Release internal references.
- */
- protected void releaseInternal() {
- definition = null;
- }
-
- /**
- * This method is a convenience for other tags for
- * putting content into the tile definition.
- * Content is already typed by caller.
- */
- public void putAttribute(String name, Object content) {
- if (content instanceof ComponentAttribute) {
- definition.putAttribute(name, (ComponentAttribute) content);
- } else {
- definition.putAttribute(name, new ComponentAttribute(content));
- }
- }
-
- /**
- * Process nested ≶put> tag.
- * Method is called from nested ≶put> tags.
- * Nested list is added to current list.
- * If role is defined, nested attribute is wrapped into an untyped definition
- * containing attribute value and role.
- */
- public void processNestedTag(PutTag nestedTag) throws JspException {
- // Get real value and check role
- // If role is set, add it in attribute definition if any.
- // If no attribute definition, create untyped one and set role.
- Object attributeValue = nestedTag.getRealValue();
- ComponentAttribute def;
-
- if (attributeValue != null
- && attributeValue instanceof ComponentAttribute) {
- def = ((ComponentAttribute) attributeValue);
- if (nestedTag.getRole() != null) {
- def.setRole(nestedTag.getRole());
- }
- } else {
- def = new ComponentAttribute(attributeValue, nestedTag.getRole(),
- nestedTag.getType());
- }
-
- // now add attribute to enclosing parent (i.e. : this object)
- putAttribute(nestedTag.getName(), def);
- }
+ private TilesContainer container;
- /**
- * Process nested ≶putList> tag.
- * Method is called from nested ≶putList> tags.
- * Nested list is added to current list.
- * If role is defined, nested attribute is wrapped into an untyped definition
- * containing attribute value and role.
- */
- public void processNestedTag(PutListTag nestedTag) throws JspException {
- // Get real value and check role
- // If role is set, add it in attribute definition if any.
- // If no attribute definition, create untyped one and set role.
- Object attributeValue = nestedTag.getList();
-
- if (nestedTag.getRole() != null) {
- ComponentAttribute def = new ComponentAttribute(attributeValue);
- def.setRole(nestedTag.getRole());
- attributeValue = def;
- }
+ private Map<String, ComponentAttribute> attributes;
- // Check if a name is defined
- if (nestedTag.getName() == null) {
- throw new JspException("Error - PutList : attribute name is not defined. It is mandatory as the list is added to a 'definition'.");
- }
- // now add attribute to enclosing parent (i.e. : this object).
- putAttribute(nestedTag.getName(), new ComponentAttribute(attributeValue));
+ public DefinitionTag() {
+ attributes = new HashMap<String, ComponentAttribute>();
}
- /**
- * Get the ID.
- *
- * @return ID
- */
public String getName() {
return name;
}
- /**
- * Set the ID.
- *
- * @param name New name.
- */
public void setName(String name) {
this.name = name;
}
- /**
- * Get the scope.
- *
- * @return Scope.
- */
public String getScope() {
return scope;
}
- /**
- * Set the scope.
- *
- * @param aScope Scope.
- */
- public void setScope(String aScope) {
- scope = aScope;
+ public void setScope(String scope) {
+ this.scope = scope;
}
- /**
- * Set <code>extends</code> (parent) definition name.
- *
- * @param definitionName Name of parent definition.
- */
- public void setExtends(String definitionName) {
- this.extendsDefinition = definitionName;
+ public String getExtendsDefinition() {
+ return extendsDefinition;
}
- /**
- * Get <code>extends</code> (parent) definition name.
- *
- * @return Name of parent definition.
- */
- public String getExtends() {
- return extendsDefinition;
+ public void setExtendsDefinition(String extendsDefinition) {
+ this.extendsDefinition = extendsDefinition;
+ }
+
+ public int doStartTag() {
+ container = TilesAccess.getContainer(pageContext.getServletContext());
+ return EVAL_BODY_INCLUDE;
}
/**
- * TODO revisit. how do we support random tiles defs in the container environment? Add a mutable container interface?
- *
- * Process the start tag by creating a new definition.
+ * TODO: Implement mutable container features.
*
- * @throws JspException On errors processing tag.
+ * @return
*/
- public int doStartTag() throws JspException {
-/*
- // Do we extend a definition ?
- if (extendsDefinition != null && !extendsDefinition.equals("")) {
- ComponentDefinition parentDef =
- TagUtils.getComponentDefinition(extendsDefinition, pageContext);
-
- definition = new ComponentDefinition(parentDef);
-
- } else {
- definition = new ComponentDefinition();
+ public int doEndTag() {
+ for(Map.Entry<String, ComponentAttribute> entry : attributes.entrySet()) {
+// container.addDefinition(entry.getKey(), entry.getValue());
}
-
- // Set definitions attributes
- if (template != null) {
- definition.setTemplate(template);
- }
-
- if (role != null) {
- definition.setRole(role);
- }
-*/
-
- return EVAL_BODY_INCLUDE;
+ return EVAL_PAGE;
}
/**
- * Process the end tag by putting the definition in appropriate context.
- *
- * @throws JspException On errors processing tag.
+ * Reset member values for reuse. This method calls super.release(),
+ * which invokes TagSupport.release(), which typically does nothing.
*/
- public int doEndTag() throws JspException {
- TagUtils.setAttribute(pageContext, name, definition, scope);
-
- releaseInternal();
- return EVAL_PAGE;
+ public void release() {
+ super.release();
+ name = null;
+ scope = null;
+ extendsDefinition = null;
+ attributes.clear();
}
+ public void processNestedTag(PutTag nestedTag) throws JspException {
+ ComponentAttribute attr = new ComponentAttribute(nestedTag.getValue(),
+ nestedTag.getRole(), nestedTag.getType());
+ attributes.put(nestedTag.getName(), attr);
+ }
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTagSupport.java (from r470901, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTagSupport.java?view=diff&rev=471458&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java&r1=470901&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTagSupport.java&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTagSupport.java Sun Nov 5 08:45:06 2006
@@ -17,7 +17,7 @@
* under the License.
*
*/
-package org.apache.tiles.taglib;
+package org.apache.tiles.taglib.definition;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.Serializable;
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTagSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTagSupport.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/InitDefinitionsTag.java (from r470971, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/InitDefinitionsTag.java?view=diff&rev=471458&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java&r1=470971&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/InitDefinitionsTag.java&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InitDefinitionsTag.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/InitDefinitionsTag.java Sun Nov 5 08:45:06 2006
@@ -19,7 +19,9 @@
*/
-package org.apache.tiles.taglib;
+package org.apache.tiles.taglib.definition;
+
+import org.apache.tiles.taglib.ComponentConstants;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/InitDefinitionsTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/InitDefinitionsTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld Sun Nov 5 08:45:06 2006
@@ -135,19 +135,6 @@
]]>
</description>
<attribute>
- <name>template</name>
- <required>false</required>
- <rtexprvalue>true</rtexprvalue>
- <description>
- <![CDATA[
- <p>A string representing the URI of a tile or template, to override the
- one specified in Tiles configuration file or in a
- <tiles:definition> tag.
- </p>
- ]]>
- </description>
- </attribute>
- <attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
@@ -303,7 +290,7 @@
</tag>
<tag>
<name>definition</name>
- <tag-class>org.apache.tiles.taglib.DefinitionTag</tag-class>
+ <tag-class>org.apache.tiles.taglib.definition.DefinitionTag</tag-class>
<body-content>JSP</body-content>
<description>
<![CDATA[
@@ -473,7 +460,13 @@
</tag>
<tag>
<name>add</name>
- <tag-class>org.apache.tiles.taglib.AddTag</tag-class>
+ <!--
+ Intentionally PutTag, it doubles for the AddTag
+ The only difference between the two is that the name
+ is not used in the Add Tag (and it's only valid within
+ the PutList
+ -->
+ <tag-class>org.apache.tiles.taglib.PutTag</tag-class>
<body-content>JSP</body-content>
<description>
<![CDATA[
@@ -585,7 +578,7 @@
<tag>
<name>useAttribute</name>
<tag-class>org.apache.tiles.taglib.UseAttributeTag</tag-class>
- <tei-class>org.apache.tiles.taglib.UseAttributeTei</tei-class>
+ <tei-class>org.apache.tiles.taglib.UseAttributeTag$Tei</tei-class>
<body-content>empty</body-content>
<description>
<![CDATA[
@@ -703,7 +696,7 @@
</tag>
<tag>
<name>initComponentDefinitions</name>
- <tag-class>org.apache.tiles.taglib.InitDefinitionsTag</tag-class>
+ <tag-class>org.apache.tiles.taglib.definition.InitDefinitionsTag</tag-class>
<body-content>empty</body-content>
<description>
<![CDATA[
Modified: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/tiles-defs.xml
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/tiles-defs.xml?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/tiles-defs.xml (original)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/WEB-INF/tiles-defs.xml Sun Nov 5 08:45:06 2006
@@ -20,25 +20,25 @@
<put name="footer" value="/common/footer.jsp" />
<put name="body" value="doc.portal.body" />
</definition>
-
+
<definition name="test.inner.definition" template="/layout.jsp">
<put name="title" value="This is a configured inner definition."/>
<put name="header" value="/header.jsp"/>
<put name="body" value="/body.jsp"/>
</definition>
-
+
<definition name="test.definition" template="/layout.jsp">
<put name="title" value="This is the title."/>
<put name="header" value="/header.jsp"/>
<put name="body" value="/body.jsp"/>
</definition>
-
+
<definition name="test.composite.definition" template="/layout.jsp">
<put name="title" value="This is a configured composite definition."/>
<put name="header" value="/header.jsp"/>
<put name="body" value="test.inner.definition"/>
</definition>
-
+
<definition name="test.putAttributes" template="/putattributeslayout.jsp">
<put name="stringTest" value="This is a string" type="string" />
<putList name="list">
@@ -46,6 +46,13 @@
<add value="valueTwo" type="string" />
<add value="valueThree" type="string" />
</putList>
+ </definition>
+
+ <definition name="test.putAllAttributes" template="/putallattributeslayout.jsp">
+ <put name="one" value="There should be three more strings" type="string" />
+ <put name="two" value="One" type="string" />
+ <put name="three" value="Two" type="string" />
+ <put name="four" value="Three" type="string" />
</definition>
<definition name="preparer.definition" template="/layout.jsp">
Modified: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp?view=diff&rev=471458&r1=471457&r2=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp (original)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp Sun Nov 5 08:45:06 2006
@@ -36,7 +36,8 @@
<a href="testput.jsp">Test Put Tag</a><br/>
<a href="testput_servlet.jsp">Test Put Tag using a servlet mapping as a template</a><br/>
<a href="testimportattribute.jsp">Test importAttribute Tag</a><br/>
-
+ <a href="testimportattribute_all.jsp">Test importAttribute Tag with not name</a><br/>
+
<h2>Currently not working tests</h2>
<a href="testdef.jsp">Test Definition Tag</a><br/>
<!-- Currently all the tests work.-->
Added: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/putallattributeslayout.jsp
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/putallattributeslayout.jsp?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/putallattributeslayout.jsp (added)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/putallattributeslayout.jsp Sun Nov 5 08:45:06 2006
@@ -0,0 +1,11 @@
+<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
+<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
+
+<tiles:importAttribute/>
+
+<c:out value="${one}"/>
+<ul>
+ <li><c:out value="${two}"/></li>
+ <li><c:out value="${three}"/></li>
+ <li><c:out value="${four}"/> </li>
+</ul>
\ No newline at end of file
Propchange: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/putallattributeslayout.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/putallattributeslayout.jsp
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev
Added: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testimportattribute_all.jsp
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testimportattribute_all.jsp?view=auto&rev=471458
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testimportattribute_all.jsp (added)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testimportattribute_all.jsp Sun Nov 5 08:45:06 2006
@@ -0,0 +1,3 @@
+<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
+
+<tiles:insertDefinition name="test.putAllAttributes" />
\ No newline at end of file
Propchange: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testimportattribute_all.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/testimportattribute_all.jsp
------------------------------------------------------------------------------
svn:keywords = Id Author Date Rev