You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2008/01/29 19:31:58 UTC
svn commit: r616470 -
/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java
Author: apetrelli
Date: Tue Jan 29 10:31:55 2008
New Revision: 616470
URL: http://svn.apache.org/viewvc?rev=616470&view=rev
Log:
TILES-208
Fixed tags to refer to non deprecated methods.
Modified:
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java?rev=616470&r1=616469&r2=616470&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java Tue Jan 29 10:31:55 2008
@@ -23,7 +23,8 @@
import org.apache.tiles.Attribute;
import javax.servlet.jsp.JspException;
-import java.util.Iterator;
+
+import java.util.Collection;
/**
@@ -75,28 +76,40 @@
pageContext.setAttribute(toName != null ? toName : name,
attribute.getValue(), scope);
} else {
- Iterator<String> names = attributeContext.getAttributeNames();
- while (names.hasNext()) {
- String name = names.next();
-
- if (name == null && !ignore) {
- throw new JspException("Error importing attributes. "
- + "Attribute with null key found.");
- } else if (name == null) {
- continue;
- }
-
- Attribute attr = attributeContext.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;
- }
+ importAttributes(attributeContext.getCascadedAttributeNames());
+ importAttributes(attributeContext.getLocalAttributeNames());
+ }
+ }
- pageContext.setAttribute(name, attr.getValue(), scope);
+ /**
+ * Imports an attribute set.
+ *
+ * @param names The names of the attributes to be imported.
+ * @throws JspException If something goes wrong during the import.
+ */
+ private void importAttributes(Collection<String> names) throws JspException {
+ if (names == null || names.isEmpty()) {
+ return;
+ }
+
+ for (String name : names) {
+ if (name == null && !ignore) {
+ throw new JspException("Error importing attributes. "
+ + "Attribute with null key found.");
+ } else if (name == null) {
+ continue;
}
+
+ Attribute attr = attributeContext.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);
}
}
}