+ gridIconSrcT="<@saf.url value='${parameters.blankIconSrc}' encode="false" />"
+ #if>
+ <#if parameters.gridIconSrcL?exists>
+ gridIconSrcL="<@saf.url value='${parameters.gridIconSrcL}' encode="false" />"
+ #if>
+ <#if parameters.gridIconSrcV?exists>
+ gridIconSrcV="<@saf.url value='${parameters.gridIconSrcV}' encode="false" />"
+ #if>
+ <#if parameters.gridIconSrcP?exists>
+ gridIconSrcP="<@saf.url value='${parameters.gridIconSrcP}' encode="false" />"
+ #if>
+ <#if parameters.gridIconSrcC?exists>
+ gridIconSrcC="<@saf.url value='${parameters.gridIconSrcC}' encode="false" />"
+ #if>
+ <#if parameters.gridIconSrcX?exists>
+ gridIconSrcX="<@saf.url value='${parameters.gridIconSrcX}' encode="false" />"
+ #if>
+ <#if parameters.gridIconSrcY?exists>
+ gridIconSrcY="<@saf.url value='${parameters.gridIconSrcY}' encode="false" />"
+ #if>
+ <#if parameters.gridIconSrcZ?exists>
+ gridIconSrcZ="<@saf.url value='${parameters.gridIconSrcZ}' encode="false" />"
+ #if>
+ <#if parameters.expandIconSrcPlus?exists>
+ expandIconSrcPlus="<@saf.url value='${parameters.expandIconSrcPlus}' />"
+ #if>
+ <#if parameters.expandIconSrcMinus?exists>
+ expandIconSrcMinus="<@saf.url value='${parameters.expandIconSrcMinus?html}' />"
+ #if>
+ <#if parameters.iconWidth?exists>
+ iconWidth="<@saf.url value='${parameters.iconWidth?html}' encode="false" />"
+ #if>
+ <#if parameters.iconHeight?exists>
+ iconHeight="<@saf.url value='${parameters.iconHeight?html}' encode="false" />"
+ #if>
+ <#if parameters.toggleDuration?exists>
+ toggleDuration=${parameters.toggleDuration?c}
+ #if>
+ <#if parameters.templateCssPath?exists>
+ templateCssPath="<@saf.url value='${parameters.templateCssPath}' encode="false" />"
+ #if>
+ <#if parameters.showGrid?exists>
+ showGrid="${parameters.showGrid?default(true)?string}"
+ #if>
+ <#if parameters.showRootGrid?exists>
+ showRootGrid="${parameters.showRootGrid?default(true)?string}"
+ #if>
+ <#if parameters.id?exists>
+ id="${parameters.id?html}"
+ #if>
<#if parameters.treeSelectedTopic?exists>
publishSelectionTopic="${parameters.treeSelectedTopic?html}"
#if>
@@ -18,14 +68,11 @@
publishCollapsedTopic="${parameters.treeCollapsedTopic?html}"
#if>
<#if parameters.toggle?exists>
- toggle="${parameters.toggle}"
- #if>
- <#if parameters.openAll?exists>
- openAll="${parameters.openAll?string}"
+ toggle="${parameters.toggle?html}"
#if>
>
<#if parameters.label?exists>
-
id="${stack.findValue(parameters.nodeIdProperty)}"
#if>
diff --git a/core/src/main/resources/template/ajax/treenode.ftl b/core/src/main/resources/template/ajax/treenode.ftl
index 08dac5713..b24fc2ee2 100644
--- a/core/src/main/resources/template/ajax/treenode.ftl
+++ b/core/src/main/resources/template/ajax/treenode.ftl
@@ -1,3 +1,6 @@
-
+ childIconSrc="<@saf.url value='${parameters.childIconSrc}' encode="false" />"
+ #if>
<#if parameters.id?exists>id="${parameters.id?html}"#if>
- title="${parameters.label?html}">
+ title="${parameters.label}">
diff --git a/core/src/test/java/org/apache/struts/action2/views/jsp/ui/Category.java b/core/src/test/java/org/apache/struts/action2/views/jsp/ui/Category.java
new file mode 100644
index 000000000..fc3553eda
--- /dev/null
+++ b/core/src/test/java/org/apache/struts/action2/views/jsp/ui/Category.java
@@ -0,0 +1,104 @@
+/*
+ * $Id: AbstractUITagTest.java 394477 2006-04-16 12:50:53Z tmjee $
+ *
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.struts.action2.views.jsp.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Used by Tree Component Test. Copied from showcase.
+ */
+public class Category {
+ private static Map
catMap = new HashMap();
+
+ static {
+ new Category(1, "Root",
+ new Category(2, "Java",
+ new Category(3, "Web Frameworks",
+ new Category(4, "WebWork"),
+ new Category(5, "Struts Action"),
+ new Category(6, "Struts Shale"),
+ new Category(7, "Stripes"),
+ new Category(8, "Rife")),
+ new Category(9, "Persistence",
+ new Category(10, "iBatis"),
+ new Category(11, "Hibernate"),
+ new Category(12, "JDO"),
+ new Category(13, "JDBC"))),
+ new Category(14, "JavaScript",
+ new Category(15, "Dojo"),
+ new Category(16, "Prototype"),
+ new Category(17, "Scriptaculous"),
+ new Category(18, "OpenRico"),
+ new Category(19, "DWR")));
+ }
+
+ public static Category getById(long id) {
+ return catMap.get(id);
+ }
+
+ private long id;
+ private String name;
+ private List children;
+ private boolean toggle;
+
+ public Category(long id, String name, Category... children) {
+ this.id = id;
+ this.name = name;
+ this.children = new ArrayList();
+ for (Category child : children) {
+ this.children.add(child);
+ }
+
+ catMap.put(id, this);
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+
+ public void toggle() {
+ toggle = !toggle;
+ }
+
+ public boolean isToggle() {
+ return toggle;
+ }
+}
diff --git a/core/src/test/java/org/apache/struts/action2/views/jsp/ui/TreeTest.java b/core/src/test/java/org/apache/struts/action2/views/jsp/ui/TreeTest.java
new file mode 100644
index 000000000..84c21f934
--- /dev/null
+++ b/core/src/test/java/org/apache/struts/action2/views/jsp/ui/TreeTest.java
@@ -0,0 +1,133 @@
+/*
+ * $Id: AbstractUITagTest.java 394477 2006-04-16 12:50:53Z tmjee $
+ *
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.struts.action2.views.jsp.ui;
+
+import org.apache.struts.action2.views.jsp.AbstractUITagTest;
+
+import com.opensymphony.xwork.Action;
+import com.opensymphony.xwork.ActionSupport;
+
+/**
+ * Test case for Tree component.
+ */
+public class TreeTest extends AbstractUITagTest{
+
+ public void testStaticTree() throws Exception {
+ // Root
+ TreeTag tag = new TreeTag();
+ tag.setShowRootGrid("false");
+ tag.setShowGrid("false");
+ tag.setTemplateCssPath("/struts/tree.css");
+ tag.setTheme("ajax");
+ tag.setPageContext(pageContext);
+ tag.setId("rootId");
+ tag.setLabel("Root");
+ tag.doStartTag();
+
+ // Child 1
+ TreeNodeTag nodeTag1 = new TreeNodeTag();
+ nodeTag1.setTheme("ajax");
+ nodeTag1.setPageContext(pageContext);
+ nodeTag1.setId("child1");
+ nodeTag1.setLabel("Child 1");
+ nodeTag1.doStartTag();
+ nodeTag1.doEndTag();
+
+ // Child 2
+ TreeNodeTag nodeTag2 = new TreeNodeTag();
+ nodeTag2.setTheme("ajax");
+ nodeTag2.setPageContext(pageContext);
+ nodeTag2.setId("child2");
+ nodeTag2.setLabel("Child 2");
+ nodeTag2.doStartTag();
+
+ // Grand Child 1
+ TreeNodeTag gNodeTag1 = new TreeNodeTag();
+ gNodeTag1.setTheme("ajax");
+ gNodeTag1.setPageContext(pageContext);
+ gNodeTag1.setId("gChild1");
+ gNodeTag1.setLabel("Grand Child 1");
+ gNodeTag1.doStartTag();
+ gNodeTag1.doEndTag();
+
+ // Grand Child 2
+ TreeNodeTag gNodeTag2 = new TreeNodeTag();
+ gNodeTag2.setTheme("ajax");
+ gNodeTag2.setPageContext(pageContext);
+ gNodeTag2.setId("gChild2");
+ gNodeTag2.setLabel("Grand Child 2");
+ gNodeTag2.doStartTag();
+ gNodeTag2.doEndTag();
+
+ // Grand Child 3
+ TreeNodeTag gNodeTag3= new TreeNodeTag();
+ gNodeTag3.setTheme("ajax");
+ gNodeTag3.setPageContext(pageContext);
+ gNodeTag3.setId("gChild3");
+ gNodeTag3.setLabel("Grand Child 3");
+ gNodeTag3.doStartTag();
+ gNodeTag3.doEndTag();
+
+ nodeTag2.doEndTag();
+
+
+ // Child 3
+ TreeNodeTag nodeTag3 = new TreeNodeTag();
+ nodeTag3.setTheme("ajax");
+ nodeTag3.setPageContext(pageContext);
+ nodeTag3.setId("child3");
+ nodeTag3.setLabel("Child 4");
+ nodeTag3.doStartTag();
+ nodeTag3.doEndTag();
+
+ tag.doEndTag();
+
+ //System.out.println(writer.toString());
+ verify(TreeTest.class.getResource("tree-1.txt"));
+ }
+
+
+
+ public void testDynamicTree() throws Exception {
+
+ TreeTag tag = new TreeTag();
+ tag.setPageContext(pageContext);
+ tag.setTheme("ajax");
+ tag.setId("myTree");
+ tag.setRootNode("%{myTreeRoot}");
+ tag.setNodeIdProperty("id");
+ tag.setNodeTitleProperty("name");
+ tag.setChildCollectionProperty("children");
+ tag.doStartTag();
+ tag.doEndTag();
+
+ //System.out.println(writer.toString());
+ verify(TreeTest.class.getResource("tree-2.txt"));
+ }
+
+
+ public Action getAction() {
+ return new InternalActionSupport();
+ }
+
+ public static class InternalActionSupport extends ActionSupport {
+ public Category getMyTreeRoot() {
+ return Category.getById(1);
+ }
+ }
+}
diff --git a/core/src/test/resources/org/apache/struts/action2/views/jsp/ui/tree-1.txt b/core/src/test/resources/org/apache/struts/action2/views/jsp/ui/tree-1.txt
new file mode 100644
index 000000000..bcd853605
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts/action2/views/jsp/ui/tree-1.txt
@@ -0,0 +1,42 @@
+
+
\ No newline at end of file
diff --git a/core/src/test/resources/org/apache/struts/action2/views/jsp/ui/tree-2.txt b/core/src/test/resources/org/apache/struts/action2/views/jsp/ui/tree-2.txt
new file mode 100644
index 000000000..76c4b5d4c
--- /dev/null
+++ b/core/src/test/resources/org/apache/struts/action2/views/jsp/ui/tree-2.txt
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file