Index: build/tomcat/tomcat-build.xmlf
===================================================================
RCS file: /home/cvs/incubator-myfaces/build/tomcat/tomcat-build.xmlf,v
retrieving revision 1.4
diff -u -r1.4 tomcat-build.xmlf
--- build/tomcat/tomcat-build.xmlf 13 Nov 2004 22:00:04 -0000 1.4
+++ build/tomcat/tomcat-build.xmlf 16 Nov 2004 05:28:39 -0000
@@ -25,16 +25,16 @@
Tree implementation based on javax.swing.JTree. The tree model is assigned by using a value binding named A hierarchy of {@link HtmlTreeNode} objects is used to represent the current
- * expanded state of the tree. The root node is held as a faces named
+ * Tree implementation based on javax.swing.JTree.
+ *
+ * The tree model is assigned by using a value binding named
+ * A hierarchy of {@link HtmlTreeNode}objects is used to represent the current
+ * expanded state of the tree. The root node is held as a faces named
+ *
+ * Revision 1.24 2004/11/15 20:14:23 David Le Strat
+ * Added support for another tree type: tree table. Added valuebinding support and
+ * table format display. Add support for rowClasses, columnClasses and var.
+ *
+ * Revision 1.23 2004/10/10 21:39:16 o_rossmueller expandAll/collapseAll
+ * (contributed by Hamidreza Sattari
+ * Revision 1.22 2004/10/10 11:21:18 o_rossmueller expandAll/collapseAll
+ * (contributed by Hamidreza Sattari
+ * Revision 1.21 2004/09/01 18:32:54 mwessendorf Organize Imports
+ *
+ * Revision 1.20 2004/08/15 15:28:04 o_rossmueller new model listener handling
+ * to get modified from events which occur outside the scope of a tree request
+ *
+ * Revision 1.19 2004/07/26 22:55:10 o_rossmueller use ids instead of clientIds
+ *
+ * Revision 1.18 2004/07/25 11:08:02 o_rossmueller use HtmlTree class name for
+ * PREVIOUS_VIEW_ROOT constant
+ *
+ * Revision 1.17 2004/07/25 11:06:38 o_rossmueller made default image paths
+ * relative (again) model and is not
- * stored in view state.rootNode.model
+ * and is not stored in view state.
+ * rootNode.
+ *
+ * Revision 1.15 2004/07/18 21:36:27 o_rossmueller fix #991740: getResourceURL + * for tree image urls + *
+ * + *+ * Revision 1.14 2004/07/11 23:38:57 o_rossmueller support multiple trees in one + * view
Revision 1.13 2004/07/01 21:53:07 mwessendorf ASF switch + * + * + * Revision 1.12 2004/05/12 02:27:43 o_rossmueller fix #951896: tree component + * works for JAVASCRIPT=false, too. + * + * + *+ * Revision 1.11 2004/05/10 01:24:51 o_rossmueller added iconClass attribute. + *
+ * + *+ * Revision 1.10 2004/05/05 00:18:57 o_rossmueller various fixes/modifications + * in model event handling and tree update. + *
+ * + *+ * Revision 1.9 2004/05/04 12:19:14 o_rossmueller added icon provider + *
+ * + *+ * Revision 1.8 2004/05/04 00:28:17 o_rossmueller model event handling + *
+ *+ * Revision 1.7 2004/04/29 18:48:16 o_rossmueller node selection handling + *
+ *+ * Revision 1.6 2004/04/23 19:09:34 o_rossmueller state transition magic + *
+ *+ * Revision 1.5 2004/04/22 23:22:33 o_rossmueller fix: queueEvent + *
+ *+ * Revision 1.4 2004/04/22 22:00:30 o_rossmueller implemented + * HtmlTree.expandPath + *
+ * + *+ * Revision 1.3 2004/04/22 21:14:55 o_rossmueller TreeSelectionListener support. + *
+ * + *+ * Revision 1.2 2004/04/22 13:00:09 o_rossmueller changed id creation - node ids + * are now generated by tree + *
+ * + *+ * Revision 1.1 2004/04/22 10:20:23 manolito tree component. + *
*/ -public class HtmlTree - extends HtmlPanelGroup - implements TreeModelListener +public class HtmlTree extends HtmlPanelGroup implements TreeModelListener { public static final int DEFAULT_EXPIRE_LISTENERS = 8 * 60 * 60 * 1000; // 8 hours - private static final String FACET_ROOTNODE = "rootNode"; + private static final String PREVIOUS_VIEW_ROOT = HtmlTree.class.getName() + ".PREVIOUS_VIEW_ROOT"; private static final int EVENT_CHANGED = 0; + private static final int EVENT_INSERTED = 1; + private static final int EVENT_REMOVED = 2; + private static final int EVENT_STRUCTURE_CHANGED = 3; private static int counter = 0; - private IconProvider iconProvider; + private boolean itemStatesRestored = false; + + private String var; + private String styleClass; + private String nodeClass; + + private String rowClasses; + + private String columnClasses; + private String selectedNodeClass; + private String iconClass; + private String iconLine = "images/tree/line.gif"; + private String iconNoline = "images/tree/noline.gif"; + private String iconChild = "images/tree/noline.gif"; + private String iconChildFirst = "images/tree/line_first.gif"; + private String iconChildMiddle = "images/tree/line_middle.gif"; + private String iconChildLast = "images/tree/line_last.gif"; + private String iconNodeOpen = "images/tree/node_open.gif"; + private String iconNodeOpenFirst = "images/tree/node_open_first.gif"; + private String iconNodeOpenMiddle = "images/tree/node_open_middle.gif"; + private String iconNodeOpenLast = "images/tree/node_open_last.gif"; + private String iconNodeClose = "images/tree/node_close.gif"; + private String iconNodeCloseFirst = "images/tree/node_close_first.gif"; + private String iconNodeCloseMiddle = "images/tree/node_close_middle.gif"; + private String iconNodeCloseLast = "images/tree/node_close_last.gif"; + private int uniqueIdCounter = 0; + private int[] selectedPath; + private int internalId; - private long expireListeners = DEFAULT_EXPIRE_LISTENERS; + private long expireListeners = DEFAULT_EXPIRE_LISTENERS; + /** + *+ * Default constructor. + *
+ */ public HtmlTree() { internalId = counter++; } - public TreeModel getModel(FacesContext context) { ValueBinding binding = getValueBinding("model"); @@ -178,270 +244,280 @@ return null; } - public String createUniqueId(FacesContext context) { return getClientId(context) + "_node_" + uniqueIdCounter++; } - public void addTreeSelectionListener(TreeSelectionListener listener) { addFacesListener(listener); } - public IconProvider getIconProvider() { return iconProvider; } - public void setIconProvider(IconProvider iconProvider) { this.iconProvider = iconProvider; } + /** + * @return Returns the var. + */ + public String getVar() + { + return var; + } + + /** + * @param var The var to set. + */ + public void setVar(String var) + { + this.var = var; + } public String getIconLine() { return iconLine; } - public void setIconLine(String iconLine) { this.iconLine = iconLine; } - public String getIconNoline() { return iconNoline; } - public void setIconNoline(String iconNoline) { this.iconNoline = iconNoline; } - public String getIconChild() { return iconChild; } - public void setIconChild(String iconChild) { this.iconChild = iconChild; } - public String getIconChildFirst() { return iconChildFirst; } - public void setIconChildFirst(String iconChildFirst) { this.iconChildFirst = iconChildFirst; } - public String getIconChildMiddle() { return iconChildMiddle; } - public void setIconChildMiddle(String iconChildMiddle) { this.iconChildMiddle = iconChildMiddle; } - public String getIconChildLast() { return iconChildLast; } - public void setIconChildLast(String iconChildLast) { this.iconChildLast = iconChildLast; } - public String getIconNodeOpen() { return iconNodeOpen; } - public void setIconNodeOpen(String iconNodeOpen) { this.iconNodeOpen = iconNodeOpen; } - public String getIconNodeOpenFirst() { return iconNodeOpenFirst; } - public void setIconNodeOpenFirst(String iconNodeOpenFirst) { this.iconNodeOpenFirst = iconNodeOpenFirst; } - public String getIconNodeOpenMiddle() { return iconNodeOpenMiddle; } - public void setIconNodeOpenMiddle(String iconNodeOpenMiddle) { this.iconNodeOpenMiddle = iconNodeOpenMiddle; } - public String getIconNodeOpenLast() { return iconNodeOpenLast; } - public void setIconNodeOpenLast(String iconNodeOpenLast) { this.iconNodeOpenLast = iconNodeOpenLast; } - public String getIconNodeClose() { return iconNodeClose; } - public void setIconNodeClose(String iconNodeClose) { this.iconNodeClose = iconNodeClose; } - public String getIconNodeCloseFirst() { return iconNodeCloseFirst; } - public void setIconNodeCloseFirst(String iconNodeCloseFirst) { this.iconNodeCloseFirst = iconNodeCloseFirst; } - public String getIconNodeCloseMiddle() { return iconNodeCloseMiddle; } - public void setIconNodeCloseMiddle(String iconNodeCloseMiddle) { this.iconNodeCloseMiddle = iconNodeCloseMiddle; } - public String getIconNodeCloseLast() { return iconNodeCloseLast; } - public void setIconNodeCloseLast(String iconNodeCloseLast) { this.iconNodeCloseLast = iconNodeCloseLast; } - public String getStyleClass() { return styleClass; } - public void setStyleClass(String styleClass) { this.styleClass = styleClass; } - public String getNodeClass() { return nodeClass; } - public void setNodeClass(String nodeClass) { this.nodeClass = nodeClass; } + /** + * @return Returns the rowClasses. + */ + public String getRowClasses() + { + return rowClasses; + } + /** + * @param rowClasses The rowClasses to set. + */ + public void setRowClasses(String rowClasses) + { + this.rowClasses = rowClasses; + } + + /** + * @return Returns the columnClasses. + */ + public String getColumnClasses() + { + return columnClasses; + } + + /** + * @param columnClasses The columnClasses to set. + */ + public void setColumnClasses(String columnClasses) + { + this.columnClasses = columnClasses; + } + + /** + * @return Returns the selectedNodeClass. + */ public String getSelectedNodeClass() { return selectedNodeClass; } - + /** + * @param selectedNodeClass The selectedNodeClass to set. + */ public void setSelectedNodeClass(String selectedNodeClass) { this.selectedNodeClass = selectedNodeClass; } - public String getIconClass() { return iconClass; } - public void setIconClass(String iconClass) { this.iconClass = iconClass; } - public long getExpireListeners() { return expireListeners; } - public void setExpireListeners(long expireListeners) { this.expireListeners = expireListeners; } - public String getFamily() { return "org.apache.myfaces.HtmlTree"; } - /** - * Ensures that the node identified by the specified path is - * expanded and viewable. If the last item in the path is a - * leaf, this will have no effect. - * + * Ensures that the node identified by the specified path is expanded and + * viewable. If the last item in the path is a leaf, this will have no + * effect. + * * @param path theTreePath identifying a node
*/
public void expandPath(TreePath path, FacesContext context)
@@ -467,11 +543,10 @@
}
}
-
/**
- * Ensures that the node identified by the specified path is
- * collapsed and viewable.
- *
+ * Ensures that the node identified by the specified path is collapsed and
+ * viewable.
+ *
* @param path the TreePath identifying a node
*/
public void collapsePath(TreePath path, FacesContext context)
@@ -484,7 +559,6 @@
}
}
-
public boolean isExpanded(TreePath path, FacesContext context)
{
if (path == null)
@@ -495,7 +569,6 @@
return findNode(path, context) != null;
}
-
private HtmlTreeNode findNode(TreePath path, FacesContext context)
{
HtmlTreeNode node = getRootNode();
@@ -513,7 +586,6 @@
return node;
}
-
public TreePath getSelectionPath()
{
if (selectedPath == null)
@@ -523,7 +595,6 @@
return HtmlTreeNode.translatePath(selectedPath, getModel(FacesContext.getCurrentInstance()));
}
-
public void selectionChanged(HtmlTreeNode node)
{
TreePath oldPath = null;
@@ -536,13 +607,13 @@
if (node.isSelected())
{
queueEvent(new TreeSelectionEvent(this, oldPath, node.getPath()));
- } else
+ }
+ else
{
queueEvent(new TreeSelectionEvent(this, oldPath, null));
}
}
-
private void createRootNode(FacesContext context)
{
HtmlTreeNode node;
@@ -552,22 +623,20 @@
String id = createUniqueId(context);
node.setId(id);
- node.setPath(new TreePath(new Object[]{root}));
+ node.setPath(new TreePath(new Object[] { root }));
node.setUserObject(root);
- node.setLayout(new int[]{HtmlTreeNode.CLOSED_SINGLE});
+ node.setLayout(new int[] { HtmlTreeNode.CLOSED_SINGLE });
getFacets().put(FACET_ROOTNODE, node);
}
-
public HtmlTreeNode getRootNode()
{
return (HtmlTreeNode) getFacet(FACET_ROOTNODE);
}
-
public Object saveState(FacesContext context)
{
- Object values[] = new Object[22];
+ Object values[] = new Object[25];
values[0] = super.saveState(context);
values[1] = iconChild;
values[2] = iconChildFirst;
@@ -590,10 +659,12 @@
values[19] = iconClass;
values[20] = new Integer(internalId);
values[21] = new Long(expireListeners);
+ values[22] = rowClasses;
+ values[23] = columnClasses;
+ values[24] = var;
return ((Object) (values));
}
-
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[]) state;
@@ -619,42 +690,41 @@
iconClass = (String) values[19];
internalId = ((Integer) values[20]).intValue();
expireListeners = ((Long) values[21]).longValue();
+ rowClasses = (String) values[22];
+ columnClasses = (String) values[23];
+ var = (String) values[24];
addToModelListeners();
}
-
public void decode(FacesContext context)
{
super.decode(context);
//Save the current view root for later reference...
context.getExternalContext().getRequestMap().put(PREVIOUS_VIEW_ROOT, context.getViewRoot());
- //...and remember that this instance needs NO special treatment on rendering:
+ //...and remember that this instance needs NO special treatment on
+ // rendering:
itemStatesRestored = true;
}
-
public void processDecodes(FacesContext context)
{
addToModelListeners();
super.processDecodes(context);
}
-
public void processValidators(FacesContext context)
{
addToModelListeners();
super.processValidators(context);
}
-
public void processUpdates(FacesContext context)
{
addToModelListeners();
super.processUpdates(context);
}
-
public void encodeBegin(FacesContext context) throws IOException
{
addToModelListeners();
@@ -673,7 +743,8 @@
if (previousRoot != null)
{
restoreItemStates(context, previousRoot);
- } else
+ }
+ else
{
//no previous root, means no decode was done
//--> a new request
@@ -683,13 +754,11 @@
super.encodeBegin(context);
}
-
public void encodeEnd(FacesContext context) throws IOException
{
super.encodeEnd(context);
}
-
public void restoreItemStates(FacesContext facesContext, UIViewRoot previousRoot)
{
HtmlTree previousTree = (HtmlTree) previousRoot.findComponent(getClientId(facesContext));
@@ -707,7 +776,6 @@
}
}
-
public void treeNodesChanged(TreeModelEvent e)
{
TreePath path = e.getTreePath();
@@ -720,7 +788,6 @@
}
}
-
public void treeNodesInserted(TreeModelEvent e)
{
TreePath path = e.getTreePath();
@@ -733,7 +800,6 @@
}
}
-
public void treeNodesRemoved(TreeModelEvent e)
{
TreePath path = e.getTreePath();
@@ -746,7 +812,6 @@
}
}
-
public void treeStructureChanged(TreeModelEvent e)
{
TreePath path = e.getTreePath();
@@ -759,7 +824,6 @@
}
}
-
public boolean equals(Object obj)
{
if (!(obj instanceof HtmlTree))
@@ -771,13 +835,11 @@
return other.getId().equals(getId());
}
-
public int hashCode()
{
return getClientId(FacesContext.getCurrentInstance()).hashCode();
}
-
public void addToModelListeners()
{
Collection listeners = getModel(FacesContext.getCurrentInstance()).getTreeModelListeners();
@@ -791,7 +853,8 @@
if (listener.getId() == internalId)
{
found = true;
- } else if (currentTime - listener.getLastAccessTime() > expireListeners)
+ }
+ else if (currentTime - listener.getLastAccessTime() > expireListeners)
{
iterator.remove();
}
@@ -802,7 +865,6 @@
}
}
-
private void processModelEvents()
{
Collection listeners = getModel(FacesContext.getCurrentInstance()).getTreeModelListeners();
@@ -824,7 +886,6 @@
}
}
-
public void collapseAll()
{
HtmlTreeNode root = getRootNode();
@@ -841,7 +902,6 @@
}
}
-
private void collapseChildren(FacesContext context, HtmlTreeNode parent)
{
for (int i = 0; i < parent.getChildren().size(); i++)
@@ -856,7 +916,6 @@
}
-
public void expandAll()
{
HtmlTreeNode root = getRootNode();
@@ -873,7 +932,6 @@
}
}
-
private void expandChildren(FacesContext context, HtmlTreeNode parent)
{
for (int i = 0; i < parent.getChildren().size(); i++)
@@ -887,71 +945,63 @@
}
}
-
private static class ModelListener implements TreeModelListener
{
private long lastAccessTime = System.currentTimeMillis();
+
private LinkedList events = new LinkedList();
- int id;
+ int id;
public ModelListener(int id)
{
this.id = id;
}
-
public List getEvents()
{
lastAccessTime = System.currentTimeMillis();
return events;
}
-
public int getId()
{
return id;
}
-
public long getLastAccessTime()
{
return lastAccessTime;
}
-
public void treeNodesChanged(TreeModelEvent e)
{
events.addLast(new Event(EVENT_CHANGED, e));
}
-
public void treeNodesInserted(TreeModelEvent e)
{
events.addLast(new Event(EVENT_INSERTED, e));
}
-
public void treeNodesRemoved(TreeModelEvent e)
{
events.addLast(new Event(EVENT_REMOVED, e));
}
-
public void treeStructureChanged(TreeModelEvent e)
{
events.addLast(new Event(EVENT_STRUCTURE_CHANGED, e));
}
}
-
private static class Event
{
private int kind;
- private TreeModelEvent event;
+ private TreeModelEvent event;
public Event(int kind, TreeModelEvent event)
{
@@ -959,24 +1009,23 @@
this.event = event;
}
-
public void process(HtmlTree tree)
{
switch (kind)
{
- case EVENT_CHANGED:
- tree.treeNodesChanged(event);
- break;
- case EVENT_INSERTED:
- tree.treeNodesInserted(event);
- break;
- case EVENT_REMOVED:
- tree.treeNodesRemoved(event);
- break;
- case EVENT_STRUCTURE_CHANGED:
- tree.treeStructureChanged(event);
- break;
+ case EVENT_CHANGED:
+ tree.treeNodesChanged(event);
+ break;
+ case EVENT_INSERTED:
+ tree.treeNodesInserted(event);
+ break;
+ case EVENT_REMOVED:
+ tree.treeNodesRemoved(event);
+ break;
+ case EVENT_STRUCTURE_CHANGED:
+ tree.treeStructureChanged(event);
+ break;
}
}
}
-}
+}
\ No newline at end of file
Index: src/components/org/apache/myfaces/custom/tree/HtmlTreeNode.java
===================================================================
RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/tree/HtmlTreeNode.java,v
retrieving revision 1.10
diff -u -r1.10 HtmlTreeNode.java
--- src/components/org/apache/myfaces/custom/tree/HtmlTreeNode.java 13 Oct 2004 11:50:58 -0000 1.10
+++ src/components/org/apache/myfaces/custom/tree/HtmlTreeNode.java 16 Nov 2004 05:28:45 -0000
@@ -23,91 +23,124 @@
import java.util.Iterator;
import java.util.List;
-
/**
- * Represents a single node of a three. A custom html link component representing the expand/collapse icon
- * is held as a facet named expandCollapse.
- *
- * @author Oliver Rossmueller
- * @version $Revision: 1.10 $ $Date: 2004/10/13 11:50:58 $
- * $Log: HtmlTreeNode.java,v $
- * Revision 1.10 2004/10/13 11:50:58 matze
- * renamed packages to org.apache
- *
- * Revision 1.9 2004/10/10 11:17:18 o_rossmueller
- * move selection up in tree when a node is removed
- *
- * Revision 1.8 2004/07/01 21:53:07 mwessendorf
- * ASF switch
- *
- * Revision 1.7 2004/05/05 00:18:57 o_rossmueller
- * various fixes/modifications in model event handling and tree update
- *
- * Revision 1.6 2004/05/04 00:28:17 o_rossmueller
- * model event handling
- *
- * Revision 1.5 2004/04/23 19:09:35 o_rossmueller
- * state transition magic
- *
- * Revision 1.4 2004/04/22 22:00:31 o_rossmueller
- * implemented HtmlTree.expandPath
- *
- * Revision 1.3 2004/04/22 21:14:56 o_rossmueller
- * TreeSelectionListener support
- *
- * Revision 1.2 2004/04/22 13:00:10 o_rossmueller
- * changed id creation - node ids are now generated by tree
- *
- * Revision 1.1 2004/04/22 10:20:23 manolito
- * tree component
+ * Represents a single node of a three. A custom html link component
+ * representing the expand/collapse icon is held as a facet named
+ * expandCollapse.
+ *
+ * @author Oliver Rossmueller
+ * @version $Revision: 1.10 $ $Date: 2004/10/13 11:50:58 $ $Log:
+ * HtmlTreeNode.java,v $
+ *
+ * + * Revision 1.10 2004/10/13 11:50:58 matze renamed packages to org.apache + *
+ * + *+ * Revision 1.9 2004/10/10 11:17:18 o_rossmueller move selection up in tree when + * a node is removed + *
+ * + *+ * Revision 1.8 2004/07/01 21:53:07 mwessendorf ASF switch + *
+ * + *+ * Revision 1.7 2004/05/05 00:18:57 o_rossmueller various fixes/modifications in + * model event handling and tree update + *
+ * + *+ * Revision 1.6 2004/05/04 00:28:17 o_rossmueller model event handling + *
+ * + *+ * Revision 1.5 2004/04/23 19:09:35 o_rossmueller state transition magic + *
+ * + *+ * Revision 1.4 2004/04/22 22:00:31 o_rossmueller implemented + * HtmlTree.expandPath + *
+ * + *+ * Revision 1.3 2004/04/22 21:14:56 o_rossmueller TreeSelectionListener support + *
+ * + *+ * Revision 1.2 2004/04/22 13:00:10 o_rossmueller changed id creation - node ids + * are now generated by tree + *
+ * + *+ * Revision 1.1 2004/04/22 10:20:23 manolito tree component + *
*/ -public class HtmlTreeNode - extends HtmlCommandLink +public class HtmlTreeNode extends HtmlCommandLink { private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlTreeNode"; public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlTreeNode"; + public static final String EXPAND_COLLAPSE_FACET = "expandCollapse"; public static final int OPEN = 0; + public static final int OPEN_FIRST = 1; + public static final int OPEN_LAST = 2; + public static final int OPEN_SINGLE = 3; + public static final int CLOSED = 10; + public static final int CLOSED_FIRST = 11; + public static final int CLOSED_LAST = 12; + public static final int CLOSED_SINGLE = 13; + public static final int CHILD = 20; + public static final int CHILD_FIRST = 21; + public static final int CHILD_LAST = 22; + public static final int CHILD_SINGLE = 23; + public static final int LINE = 30; + public static final int EMPTY = 40; + private static final int OFFSET = 10; + private static final int MOD_FIRST = 1; + private static final int MOD_LAST = 2; private transient TreePath path; + private int[] translatedPath; + private transient Object userObject; + private boolean expanded = false; + private boolean selected = false; - private int[] layout; + private int[] layout; public HtmlTreeNode() { setRendererType(DEFAULT_RENDERER_TYPE); } - public int getLevel() { return layout.length - 1; } - public int getMaxChildLevel() { if (getChildCount() == 0) @@ -124,7 +157,6 @@ return max; } - public TreePath getPath() { if (path == null) @@ -138,13 +170,11 @@ return path; } - public void setPath(TreePath path) { this.path = path; } - int[] getTranslatedPath() { if (translatedPath != null) @@ -155,7 +185,6 @@ return translatePath(getPath(), getTreeModel(FacesContext.getCurrentInstance())); } - public Object getUserObject() { if (userObject == null) @@ -165,20 +194,17 @@ return userObject; } - public void setUserObject(Object userObject) { this.userObject = userObject; - setValue(userObject.toString()); + setValue(userObject); } - public boolean isExpanded() { return expanded; } - void childrenAdded(int[] children, FacesContext context) { if (getChildCount() == 0 && children.length > 0) @@ -206,7 +232,6 @@ } } - void childrenChanged(int[] children, FacesContext context) { if (!expanded) @@ -227,7 +252,6 @@ } } - private void addNode(TreeModel model, Object userObject, int index, int childCount, FacesContext context) { HtmlTreeNode node = createNode(model, userObject, childCount, index, context); @@ -244,7 +268,8 @@ // change from *_FIRST to * layout[layout.length - 1]--; } - } else if (index == childCount - 1) + } + else if (index == childCount - 1) { HtmlTreeNode last = (HtmlTreeNode) getChildren().get(childCount - 2); int[] layout = last.getLayout(); @@ -259,7 +284,6 @@ children.add(index, node); } - void childrenRemoved(int[] children) { if (!expanded) @@ -275,14 +299,21 @@ translateChildrenPath(pathUpdateIndex, children[i], -1); HtmlTreeNode child = (HtmlTreeNode) childNodes.get(children[i]); - if (child.isSelected()) { + if (child.isSelected()) + { child.setSelected(false); - if (children[i] < childNodes.size() - 1) { + if (children[i] < childNodes.size() - 1) + { ((HtmlTreeNode) childNodes.get(children[i] + 1)).setSelected(true); - } else { - if (children[i] > 0) { + } + else + { + if (children[i] > 0) + { ((HtmlTreeNode) childNodes.get(children[i] - 1)).setSelected(true); - } else { + } + else + { setSelected(true); } } @@ -291,26 +322,26 @@ } } - /** - * Update the translatedPath of all child nodes so the path points to the same object in the model - * after adding/removing a node - * + * Update the translatedPath of all child nodes so the path points to the + * same object in the model after adding/removing a node + * * @param pathUpdateIndex * @param startIndex * @param offset */ - private void translateChildrenPath(int pathUpdateIndex, int startIndex, int offset) { + private void translateChildrenPath(int pathUpdateIndex, int startIndex, int offset) + { List children = getChildren(); int childrenSize = children.size(); - for (int i = startIndex; i < childrenSize; i++) { + for (int i = startIndex; i < childrenSize; i++) + { HtmlTreeNode node = (HtmlTreeNode) children.get(i); node.updateTranslatedPath(pathUpdateIndex, offset); } } - private void updateTranslatedPath(int pathUpdateIndex, int offset) { translatedPath[pathUpdateIndex] += offset; @@ -318,13 +349,13 @@ path = null; userObject = null; - if (isExpanded()) { + if (isExpanded()) + { // continue with the children of this node translateChildrenPath(pathUpdateIndex, 0, offset); } } - public void setExpanded(boolean expanded) { if (this.expanded == expanded) @@ -347,7 +378,8 @@ getChildren().add(node); } layout[layout.length - 1] -= OFFSET; - } else + } + else { if (clearSelection()) { @@ -359,7 +391,6 @@ } - private HtmlTreeNode createNode(TreeModel model, Object child, int childCount, int index, FacesContext context) { HtmlTreeNode node = (HtmlTreeNode) context.getApplication().createComponent(HtmlTreeNode.COMPONENT_TYPE); @@ -379,29 +410,35 @@ if (index == 0) { state = CHILD; - } else if (index == childCount - 1) + } + else if (index == childCount - 1) { state = CHILD_LAST; } - } else + } + else { state = CHILD_LAST; } - } else + } + else { if (childCount > 1) { if (index == 0) { state = CLOSED; - } else if (index == childCount - 1) + } + else if (index == childCount - 1) { state = CLOSED_LAST; - } else + } + else { state = CLOSED; } - } else + } + else { state = CLOSED_LAST; } @@ -412,19 +449,16 @@ return node; } - public void toggleExpanded() { setExpanded(!expanded); } - public boolean isSelected() { return selected; } - public void setSelected(boolean selected) { if (selected) @@ -435,13 +469,11 @@ getTree().selectionChanged(this); } - public void toggleSelected() { setSelected(!selected); } - private boolean clearSelection() { if (isSelected()) @@ -460,19 +492,16 @@ return false; } - public int[] getLayout() { return layout; } - public void setLayout(int[] layout) { this.layout = layout; } - public void setLayout(int[] parentLayout, int layout) { this.layout = new int[parentLayout.length + 1]; @@ -481,24 +510,26 @@ for (int i = 0; i < parentLayout.length; i++) { int state = parentLayout[i]; - if (state == OPEN || state == OPEN_FIRST || state == CLOSED || state == CLOSED_FIRST || state == CHILD || state == CHILD_FIRST || state == LINE) + if (state == OPEN || state == OPEN_FIRST || state == CLOSED || state == CLOSED_FIRST || state == CHILD + || state == CHILD_FIRST || state == LINE) { this.layout[i] = LINE; - } else + } + else { this.layout[i] = EMPTY; } } } - public HtmlTreeImageCommandLink getExpandCollapseCommand(FacesContext context) { HtmlTreeImageCommandLink command = (HtmlTreeImageCommandLink) getFacet(EXPAND_COLLAPSE_FACET); if (command == null) { - command = (HtmlTreeImageCommandLink) context.getApplication().createComponent(HtmlTreeImageCommandLink.COMPONENT_TYPE); + command = (HtmlTreeImageCommandLink) context.getApplication().createComponent( + HtmlTreeImageCommandLink.COMPONENT_TYPE); String id = getTree().createUniqueId(context); command.setId(id); getFacets().put(EXPAND_COLLAPSE_FACET, command); @@ -506,7 +537,6 @@ return command; } - public Object saveState(FacesContext context) { Object values[] = new Object[5]; @@ -518,7 +548,6 @@ return ((Object) (values)); } - public void restoreState(FacesContext context, Object state) { Object values[] = (Object[]) state; @@ -529,7 +558,6 @@ selected = ((Boolean) values[4]).booleanValue(); } - protected static int[] translatePath(TreePath treePath, TreeModel model) { Object[] path = treePath.getPath(); @@ -546,7 +574,6 @@ return translated; } - protected static TreePath translatePath(int[] path, TreeModel model) { Object[] translated = new Object[path.length + 1]; @@ -563,13 +590,11 @@ return new TreePath(translated); } - protected TreeModel getTreeModel(FacesContext context) { return getTree().getModel(context); } - protected HtmlTree getTree() { if (getParent() instanceof HtmlTree) @@ -579,13 +604,11 @@ return ((HtmlTreeNode) getParent()).getTree(); } - public boolean isLeaf(FacesContext context) { return getTreeModel(context).isLeaf(getUserObject()); } - public void expandPath(int[] translatedPath, int current) { if (current >= translatedPath.length) @@ -603,7 +626,6 @@ child.expandPath(translatedPath, current + 1); } - public void restoreItemState(HtmlTreeNode node) { setExpanded(node.isExpanded()); @@ -616,4 +638,4 @@ child.restoreItemState((HtmlTreeNode) otherChildren.get(i)); } } -} +} \ No newline at end of file Index: src/components/org/apache/myfaces/custom/tree/Tree.xml =================================================================== RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/tree/Tree.xml,v retrieving revision 1.3 diff -u -r1.3 Tree.xml --- src/components/org/apache/myfaces/custom/tree/Tree.xml 29 Oct 2004 15:51:05 -0000 1.3 +++ src/components/org/apache/myfaces/custom/tree/Tree.xml 16 Nov 2004 05:28:45 -0000 @@ -1,4 +1,20 @@ + + @@ -13,6 +29,10 @@+ * Revision 1.4 2004/11/15 20:14:23 David Le Strat + * Added getter for userObject property. + *
+ * + *+ * Revision 1.3 2004/10/13 11:50:58 matze renamed packages to org.apache + *
+ * + *+ * Revision 1.2 2004/07/01 21:53:07 mwessendorf ASF switch + *
+ * + *+ * Revision 1.1 2004/04/22 10:20:23 manolito tree component + *
+ * */ public interface TreeNode { /** + * @return Gets the user object of this node. + */ + Object getUserObject(); + + /** * Answer the child at the given index. */ TreeNode getChildAt(int childIndex); - /** * Answer the number of children this node contains. */ int getChildCount(); - /** * Answer the parent of this node. */ TreeNode getParent(); - /** * Answer the index of the given node in this node's children. */ int getIndex(TreeNode node); - /** * Answer true if this node allows children. */ boolean getAllowsChildren(); - /** * Answer true if this is a leaf node. */ boolean isLeaf(); - /** * Answer the children of the receiver. The base collection is unmodifyable. */ Iterator children(); -} +} \ No newline at end of file Index: src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java =================================================================== RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java,v retrieving revision 1.6 diff -u -r1.6 HtmlTreeImageCommandLinkRenderer.java --- src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java 13 Oct 2004 11:50:58 -0000 1.6 +++ src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeImageCommandLinkRenderer.java 16 Nov 2004 05:28:45 -0000 @@ -26,7 +26,6 @@ import javax.faces.context.ResponseWriter; import java.io.IOException; - /** * @author Oliver Rossmueller * @version $Revision: 1.6 $ $Date: 2004/10/13 11:50:58 $ Index: src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeNodeRenderer.java =================================================================== RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeNodeRenderer.java,v retrieving revision 1.7 diff -u -r1.7 HtmlTreeNodeRenderer.java --- src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeNodeRenderer.java 13 Oct 2004 11:50:58 -0000 1.7 +++ src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeNodeRenderer.java 16 Nov 2004 05:28:45 -0000 @@ -23,47 +23,57 @@ import javax.faces.context.FacesContext; /** - * @author Oliver Rossmueller - * @version $Revision: 1.7 $ $Date: 2004/10/13 11:50:58 $ - * $Log: HtmlTreeNodeRenderer.java,v $ - * Revision 1.7 2004/10/13 11:50:58 matze - * renamed packages to org.apache - * - * Revision 1.6 2004/07/01 21:53:10 mwessendorf - * ASF switch - * - * Revision 1.5 2004/06/09 20:32:16 o_rossmueller - * fix: removed duplicate output of value - * - * Revision 1.4 2004/06/03 12:57:03 o_rossmueller - * modified link renderer to use one hidden field for all links according to 1.1 renderkit docs - * added onclick=clear_XXX to button - * - * Revision 1.3 2004/05/27 15:06:39 manolito - * bugfix: node labels not rendered any more - * - * Revision 1.2 2004/04/29 18:48:07 o_rossmueller - * node selection handling - * - * Revision 1.1 2004/04/22 10:20:24 manolito - * tree component - * + * @author Oliver Rossmueller + * @version $Revision: 1.7 $ $Date: 2004/10/13 11:50:58 $ $Log: + * HtmlTreeNodeRenderer.java,v $ + * + *+ * Revision 1.7 2004/10/13 11:50:58 matze renamed packages to org.apache + *
+ * + *+ * Revision 1.6 2004/07/01 21:53:10 mwessendorf ASF switch + *
+ * + *+ * Revision 1.5 2004/06/09 20:32:16 o_rossmueller fix: removed duplicate output + * of value + *
+ * + *+ * Revision 1.4 2004/06/03 12:57:03 o_rossmueller modified link renderer to use + * one hidden field for all links according to 1.1 renderkit docs added + * onclick=clear_XXX to button + *
+ * + *+ * Revision 1.3 2004/05/27 15:06:39 manolito bugfix: node labels not rendered + * any more + *
+ * + *+ * Revision 1.2 2004/04/29 18:48:07 o_rossmueller node selection handling + *
+ * + *+ * Revision 1.1 2004/04/22 10:20:24 manolito tree component + *
+ * */ -public class HtmlTreeNodeRenderer - extends HtmlLinkRendererBase +public class HtmlTreeNodeRenderer extends HtmlLinkRendererBase { - public void decode(FacesContext facesContext, UIComponent component) { super.decode(facesContext, component); String clientId = component.getClientId(facesContext); - String reqValue = (String)facesContext.getExternalContext().getRequestParameterMap().get(HtmlRendererUtils.getHiddenCommandLinkFieldName(HtmlRendererUtils.getFormName(component, facesContext))); + String reqValue = (String) facesContext.getExternalContext().getRequestParameterMap() + .get(HtmlRendererUtils.getHiddenCommandLinkFieldName(HtmlRendererUtils.getFormName(component, + facesContext))); if (reqValue != null && reqValue.equals(clientId)) { - HtmlTreeNode node = (HtmlTreeNode)component; - + HtmlTreeNode node = (HtmlTreeNode) component; node.setSelected(true); } } -} +} \ No newline at end of file Index: src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java =================================================================== RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java,v retrieving revision 1.10 diff -u -r1.10 HtmlTreeRenderer.java --- src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java 13 Oct 2004 11:50:58 -0000 1.10 +++ src/components/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java 16 Nov 2004 05:28:47 -0000 @@ -16,77 +16,99 @@ package org.apache.myfaces.custom.tree.renderkit.html; import org.apache.myfaces.custom.tree.HtmlTree; +import org.apache.myfaces.custom.tree.HtmlTreeColumn; import org.apache.myfaces.custom.tree.HtmlTreeImageCommandLink; import org.apache.myfaces.custom.tree.HtmlTreeNode; import org.apache.myfaces.custom.tree.IconProvider; +import org.apache.myfaces.custom.tree.TreeNode; import org.apache.myfaces.renderkit.RendererUtils; import org.apache.myfaces.renderkit.html.HTML; -import org.apache.myfaces.renderkit.html.HtmlRenderer; import org.apache.myfaces.renderkit.html.HtmlRendererUtils; +import org.apache.myfaces.renderkit.html.HtmlTableRendererBase; +import org.apache.myfaces.util.ArrayUtils; +import org.apache.myfaces.util.StringUtils; +import javax.faces.component.UIColumn; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; + import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; - /** - * @author Oliver Rossmueller - * @version $Revision: 1.10 $ $Date: 2004/10/13 11:50:58 $ - * $Log: HtmlTreeRenderer.java,v $ - * Revision 1.10 2004/10/13 11:50:58 matze + * @author Oliver Rossmueller + * @version $Revision: 1.10 $ $Date: 2004/10/13 11:50:58 $ $Log: + * HtmlTreeRenderer.java,v $ Revision 1.10 2004/10/13 11:50:58 matze * renamed packages to org.apache - * - * Revision 1.9 2004/07/18 21:36:25 o_rossmueller - * fix #991740: getResourceURL for tree image urls - * - * Revision 1.8 2004/07/01 21:53:10 mwessendorf - * ASF switch - * - * Revision 1.7 2004/05/27 15:06:39 manolito - * bugfix: node labels not rendered any more - * - * Revision 1.6 2004/05/12 02:27:43 o_rossmueller - * fix #951896: tree component works for JAVASCRIPT=false, too - * - * Revision 1.5 2004/05/10 01:24:51 o_rossmueller - * added iconClass attribute - * - * Revision 1.4 2004/05/04 12:19:13 o_rossmueller - * added icon provider - * - * Revision 1.3 2004/04/23 19:09:34 o_rossmueller - * state transition magic - * - * Revision 1.2 2004/04/22 12:57:39 o_rossmueller - * fixed leaf node layout - * - * Revision 1.1 2004/04/22 10:20:24 manolito - * tree component + * + *+ * Revision 1.10 2004/11/15 20:14:23 David + * Le Strat Added support for another tree type: tree table. Added + * valuebinding support and table format display. + *
+ * + *+ * Revision 1.9 2004/07/18 21:36:25 o_rossmueller fix #991740: getResourceURL + * for tree image urls + *
+ * + *+ * Revision 1.8 2004/07/01 21:53:10 mwessendorf ASF switch + *
+ * + *+ * Revision 1.7 2004/05/27 15:06:39 manolito bugfix: node labels not rendered + * any more + *
+ * + *+ * Revision 1.6 2004/05/12 02:27:43 o_rossmueller fix #951896: tree component + * works for JAVASCRIPT=false, too + *
+ * + *+ * Revision 1.5 2004/05/10 01:24:51 o_rossmueller added iconClass attribute + *
+ * + *+ * Revision 1.4 2004/05/04 12:19:13 o_rossmueller added icon provider + *
+ * + *+ * Revision 1.3 2004/04/23 19:09:34 o_rossmueller state transition magic + *
+ * + *+ * Revision 1.2 2004/04/22 12:57:39 o_rossmueller fixed leaf node layout + *
+ * + *+ * Revision 1.1 2004/04/22 10:20:24 manolito tree component + *
*/ -public class HtmlTreeRenderer - extends HtmlRenderer +public class HtmlTreeRenderer extends HtmlTableRendererBase { private static final Integer ZERO = new Integer(0); - public boolean getRendersChildren() { return true; } + public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException + { + // Rendering occurs in encodeEnd. + } public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException { - //super.encodeChildren(facesContext, component); // children are rendered in encodeEnd } - public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException { RendererUtils.checkParamValidity(facesContext, component, HtmlTree.class); @@ -102,30 +124,192 @@ int maxLevel = tree.getRootNode().getMaxChildLevel(); - // create initial children list from root node facet + // Create initial children list from root node facet ArrayList childNodes = new ArrayList(1); childNodes.add(tree.getRootNode()); + // Render header. + renderFacet(facesContext, writer, component, true, maxLevel); + + // Render children. renderChildren(facesContext, writer, tree, childNodes, maxLevel, tree.getIconProvider()); - HtmlRendererUtils.writePrettyLineSeparator(facesContext); + // Render footer. + renderFacet(facesContext, writer, component, false, maxLevel); writer.endElement(HTML.TABLE_ELEM); - super.encodeEnd(facesContext, component); } + /** + *+ * Overrides super renderFacet to render the {@link HtmlTree} facets. + *
+ * + * @param facesContext The facesContext + * @param writer The writer. + * @param component The component. + * @param header Whether there is a header. + * @param maxLevel The max level for the rendered tree. + * @throws IOException Throws IOException. + */ + protected void renderFacet(FacesContext facesContext, ResponseWriter writer, UIComponent component, boolean header, int maxLevel) + throws IOException + { + int colspan = 0; + boolean hasColumnFacet = false; + for (Iterator it = component.getChildren().iterator(); it.hasNext();) + { + UIComponent uiComponent = (UIComponent) it.next(); + if ((uiComponent.getFamily().equals(UIColumn.COMPONENT_FAMILY)) + && ((UIColumn) uiComponent).isRendered()) + { + colspan++; + if (!hasColumnFacet) + { + hasColumnFacet = header ? ((UIColumn) uiComponent).getHeader() != null : ((UIColumn) uiComponent) + .getFooter() != null; + } + } + else if ((uiComponent.getFamily().equals(HtmlTreeColumn.COMPONENT_FAMILY)) + && ((HtmlTreeColumn) uiComponent).isRendered()) + { + colspan += maxLevel + 3; + if (!hasColumnFacet) + { + hasColumnFacet = header ? ((UIColumn) uiComponent).getHeader() != null : ((UIColumn) uiComponent) + .getFooter() != null; + } + } + } + + UIComponent facet = header ? (UIComponent) component.getFacets().get(HEADER_FACET_NAME) + : (UIComponent) component.getFacets().get(FOOTER_FACET_NAME); + if (facet != null || hasColumnFacet) + { + // Header or Footer present + String elemName = header ? HTML.THEAD_ELEM : HTML.TFOOT_ELEM; + + HtmlRendererUtils.writePrettyLineSeparator(facesContext); + writer.startElement(elemName, component); + if (header) + { + String headerStyleClass = getHeaderClass(component); + if (facet != null) + renderTableHeaderRow(facesContext, writer, component, facet, headerStyleClass, colspan); + if (hasColumnFacet) + renderColumnHeaderRow(facesContext, writer, component, headerStyleClass, maxLevel); + } + else + { + String footerStyleClass = getFooterClass(component); + if (hasColumnFacet) + renderColumnFooterRow(facesContext, writer, component, footerStyleClass, maxLevel); + if (facet != null) + renderTableFooterRow(facesContext, writer, component, facet, footerStyleClass, colspan); + } + writer.endElement(elemName); + } + } + + protected void renderColumnHeaderRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + String headerStyleClass, int maxLevel) throws IOException + { + renderColumnHeaderOrFooterRow(facesContext, writer, component, headerStyleClass, true, maxLevel); + } - protected void renderChildren(FacesContext facesContext, - ResponseWriter writer, - HtmlTree tree, - List children, - int maxLevel, - IconProvider iconProvider) throws IOException + protected void renderColumnFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + String footerStyleClass, int maxLevel) throws IOException { - String iconClass = tree.getIconClass(); + renderColumnHeaderOrFooterRow(facesContext, writer, component, footerStyleClass, false, maxLevel); + } + + private void renderColumnHeaderOrFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + String styleClass, boolean header, int maxLevel) throws IOException + { + HtmlRendererUtils.writePrettyLineSeparator(facesContext); + writer.startElement(HTML.TR_ELEM, component); + for (Iterator it = component.getChildren().iterator(); it.hasNext();) + { + UIComponent uiComponent = (UIComponent) it.next(); + if ((uiComponent.getFamily().equals(UIColumn.COMPONENT_FAMILY)) + && ((UIColumn) uiComponent).isRendered()) + { + if (header) + { + renderColumnHeaderCell(facesContext, writer, (UIColumn) uiComponent, styleClass, 0); + } + else + { + renderColumnFooterCell(facesContext, writer, (UIColumn) uiComponent, styleClass, 0); + } + } + else if ((uiComponent.getFamily().equals(HtmlTreeColumn.COMPONENT_FAMILY)) + && ((HtmlTreeColumn) uiComponent).isRendered()) + { + if (header) + { + renderColumnHeaderCell(facesContext, writer, (UIColumn) uiComponent, styleClass, maxLevel + 3); + } + else + { + renderColumnFooterCell(facesContext, writer, (UIColumn) uiComponent, styleClass, maxLevel + 3); + } + } + } + writer.endElement(HTML.TR_ELEM); + } + + /** + *
+ * Renders the children. + *
+ * + * @param facesContext The facesContext. + * @param writer The writer. + * @param tree The tree component. + * @param children The children to render. + * @param maxLevel The maximum level. + * @param iconProvider The icon provider. + * @throws IOException Throws an IOException. + */ + protected void renderChildren(FacesContext facesContext, ResponseWriter writer, HtmlTree tree, List children, + int maxLevel, IconProvider iconProvider) throws IOException + { + renderChildren(facesContext, writer, tree, children, maxLevel, iconProvider, 0); + } + + /** + *+ * Renders the children given the rowClassIndex. + *
+ * + * @param facesContext The facesContext. + * @param writer The writer. + * @param tree The tree component. + * @param children The children to render. + * @param maxLevel The maximum level. + * @param iconProvider The icon provider. + * @param rowClassIndex The row class index. + * @throws IOException Throws an IOException. + */ + protected void renderChildren(FacesContext facesContext, ResponseWriter writer, HtmlTree tree, List children, + int maxLevel, IconProvider iconProvider, int rowClassIndex) throws IOException + { + String rowClasses = tree.getRowClasses(); + String columnClasses = tree.getColumnClasses(); + + String[] rowClassesArray = (rowClasses == null) ? ArrayUtils.EMPTY_STRING_ARRAY : StringUtils.trim(StringUtils + .splitShortString(rowClasses, ',')); + int rowClassesCount = rowClassesArray.length; + + String[] columnClassesArray = (columnClasses == null) ? ArrayUtils.EMPTY_STRING_ARRAY : StringUtils + .trim(StringUtils.splitShortString(columnClasses, ',')); + int columnClassesCount = columnClassesArray.length; + int columnClassIndex = 0; for (Iterator it = children.iterator(); it.hasNext();) { HtmlTreeNode child = (HtmlTreeNode) it.next(); + if (!child.isRendered()) { continue; @@ -134,138 +318,233 @@ writer.startElement(HTML.TR_ELEM, null); - int[] layout = child.getLayout(); + if (rowClassIndex < rowClassesCount) + { + writer.writeAttribute(HTML.CLASS_ATTR, rowClassesArray[rowClassIndex], null); + } + if (rowClassesCount > 0) + { + rowClassIndex++; + rowClassIndex = rowClassIndex % rowClassesCount; + } - // tree lines - for (int i = 0; i < layout.length - 1; i++) + if (null != tree.getVar()) { - int state = layout[i]; - writer.startElement(HTML.TD_ELEM, null); - String url = getLayoutImage(tree, state); + facesContext.getExternalContext().getRequestMap().put(tree.getVar(), + ((TreeNode) child.getUserObject()).getUserObject()); + } - if ((url != null) && (url.length() > 0)) + List componentChildren = tree.getChildren(); + if ((null != componentChildren) && (componentChildren.size() > 0)) + { + for (int j = 0, size = tree.getChildCount(); j < size; j++) { - writer.startElement(HTML.IMG_ELEM, child); - - String src; - if (url.startsWith(HTML.HREF_PATH_SEPARATOR)) + UIComponent componentChild = (UIComponent) componentChildren.get(j); + if ((componentChild.getFamily().equals(UIColumn.COMPONENT_FAMILY)) + && ((UIColumn) componentChild).isRendered()) { - String path = facesContext.getExternalContext().getRequestContextPath(); - src = path + url; - } else + writer.startElement(HTML.TD_ELEM, tree); + if (columnClassIndex < columnClassesCount) + { + writer.writeAttribute(HTML.CLASS_ATTR, columnClassesArray[columnClassIndex], null); + } + if (columnClassesCount > 0) + { + columnClassIndex++; + columnClassIndex = columnClassIndex % columnClassesCount; + } + RendererUtils.renderChild(facesContext, componentChild); + writer.endElement(HTML.TD_ELEM); + } + else if ((componentChild.getFamily().equals(HtmlTreeColumn.COMPONENT_FAMILY)) + && ((HtmlTreeColumn) componentChild).isRendered()) { - src = url; + renderTreeColumnChild(facesContext, writer, componentChild, tree, child, maxLevel, iconProvider); } - //Encode URL - //Although this is an url url, encodeURL is no nonsense, because the - //actual url url could also be a dynamic servlet request: - src = facesContext.getExternalContext().encodeResourceURL(src); - writer.writeAttribute(HTML.SRC_ATTR, src, null); - writer.writeAttribute(HTML.BORDER_ATTR, ZERO, null); + } + } + else + { + renderTreeColumnChild(facesContext, writer, null, tree, child, maxLevel, iconProvider); + } - HtmlRendererUtils.renderHTMLAttributes(writer, child, HTML.IMG_PASSTHROUGH_ATTRIBUTES); + writer.endElement(HTML.TR_ELEM); - writer.endElement(HTML.IMG_ELEM); + if (child.getChildCount() > 0) + { + renderChildren(facesContext, writer, tree, child.getChildren(), maxLevel, iconProvider, rowClassIndex); + if (rowClassesCount > 0) + { + rowClassIndex += (child.getChildCount() % rowClassesCount); + rowClassIndex = rowClassIndex % rowClassesCount; } - writer.endElement(HTML.TD_ELEM); - } + } + } - // command link + /** + *+ * Render the column where the tree is displayed. + *
+ * + * @param facesContext The facesContext. + * @param writer The writer. + * @param component The component that will contain the tree. Null for + * default tree or {@link HtmlTreeColumn}for table rendering. + * @param tree The tree, + * @param child The tree node child. + * @param maxLevel The max number of levels. + * @param iconProvider The iconProvider. + * @throws IOException Throws IOException. + */ + protected void renderTreeColumnChild(FacesContext facesContext, ResponseWriter writer, UIComponent component, + HtmlTree tree, HtmlTreeNode child, int maxLevel, IconProvider iconProvider) throws IOException + { + String iconClass = tree.getIconClass(); + int[] layout = child.getLayout(); + // tree lines + for (int i = 0; i < layout.length - 1; i++) + { + int state = layout[i]; writer.startElement(HTML.TD_ELEM, null); - int state = layout[layout.length - 1]; String url = getLayoutImage(tree, state); - if (state == HtmlTreeNode.CHILD || state == HtmlTreeNode.CHILD_FIRST || state == HtmlTreeNode.CHILD_SINGLE || state == HtmlTreeNode.CHILD_LAST) + if ((url != null) && (url.length() > 0)) { - // no action, just img + writer.startElement(HTML.IMG_ELEM, child); + String src; + if (url.startsWith(HTML.HREF_PATH_SEPARATOR)) + { + String path = facesContext.getExternalContext().getRequestContextPath(); + src = path + url; + } + else + { + src = url; + } + //Encode URL + //Although this is an url url, encodeURL is no nonsense, + // because the + //actual url url could also be a dynamic servlet request: + src = facesContext.getExternalContext().encodeResourceURL(src); + writer.writeAttribute(HTML.SRC_ATTR, src, null); + writer.writeAttribute(HTML.BORDER_ATTR, ZERO, null); - writeImageElement(url, facesContext, writer, child); - - } else - { - HtmlTreeImageCommandLink expandCollapse = (HtmlTreeImageCommandLink) child.getExpandCollapseCommand(facesContext); - expandCollapse.setImage(getLayoutImage(tree, layout[layout.length - 1])); + HtmlRendererUtils.renderHTMLAttributes(writer, child, HTML.IMG_PASSTHROUGH_ATTRIBUTES); - expandCollapse.encodeBegin(facesContext); - expandCollapse.encodeEnd(facesContext); + writer.endElement(HTML.IMG_ELEM); } writer.endElement(HTML.TD_ELEM); + } - int labelColSpan = maxLevel - child.getLevel() + 1; + // command link + writer.startElement(HTML.TD_ELEM, null); + int state = layout[layout.length - 1]; + String url = getLayoutImage(tree, state); - // node icon - if (iconProvider != null) - { - url = iconProvider.getIconUrl(child.getUserObject(), child.getChildCount(), child.isLeaf(facesContext)); - } else - { - if (!child.isLeaf(facesContext)) - { - // todo: icon provider - url = "images/tree/folder.gif"; - } else - { - url = null; - } - } + if (state == HtmlTreeNode.CHILD || state == HtmlTreeNode.CHILD_FIRST || state == HtmlTreeNode.CHILD_SINGLE + || state == HtmlTreeNode.CHILD_LAST) + { + // no action, just img + writeImageElement(url, facesContext, writer, child); + } + else + { + HtmlTreeImageCommandLink expandCollapse = (HtmlTreeImageCommandLink) child + .getExpandCollapseCommand(facesContext); + expandCollapse.setImage(getLayoutImage(tree, layout[layout.length - 1])); - if ((url != null) && (url.length() > 0)) + expandCollapse.encodeBegin(facesContext); + expandCollapse.encodeEnd(facesContext); + } + writer.endElement(HTML.TD_ELEM); + + int labelColSpan = maxLevel - child.getLevel() + 1; + + // node icon + if (iconProvider != null) + { + url = iconProvider.getIconUrl(child.getUserObject(), child.getChildCount(), child.isLeaf(facesContext)); + } + else + { + if (!child.isLeaf(facesContext)) { - writer.startElement(HTML.TD_ELEM, null); - if (iconClass != null) { - writer.writeAttribute(HTML.CLASS_ATTR, iconClass, null); - } - writeImageElement(url, facesContext, writer, child); - writer.endElement(HTML.TD_ELEM); - } else + // todo: icon provider + url = "images/tree/folder.gif"; + } + else { - // no icon, so label has more room - labelColSpan++; + url = null; } + } - - // node label + if ((url != null) && (url.length() > 0)) + { writer.startElement(HTML.TD_ELEM, null); - writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(labelColSpan), null); - if (child.isSelected() && tree.getSelectedNodeClass() != null) + if (iconClass != null) { - writer.writeAttribute(HTML.CLASS_ATTR, tree.getSelectedNodeClass(), null); - } else if (!child.isSelected() && tree.getNodeClass() != null) - { - writer.writeAttribute(HTML.CLASS_ATTR, tree.getNodeClass(), null); + writer.writeAttribute(HTML.CLASS_ATTR, iconClass, null); } - child.encodeBegin(facesContext); - child.encodeEnd(facesContext); + writeImageElement(url, facesContext, writer, child); writer.endElement(HTML.TD_ELEM); + } + else + { + // no icon, so label has more room + labelColSpan++; + } - writer.endElement(HTML.TR_ELEM); + // node label + writer.startElement(HTML.TD_ELEM, null); + writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(labelColSpan), null); + if (child.isSelected() && tree.getSelectedNodeClass() != null) + { + writer.writeAttribute(HTML.CLASS_ATTR, tree.getSelectedNodeClass(), null); + } + else if (!child.isSelected() && tree.getNodeClass() != null) + { + writer.writeAttribute(HTML.CLASS_ATTR, tree.getNodeClass(), null); + } - if (child.getChildCount() > 0) + List componentChildren = null; + if (null != component) + { + componentChildren = component.getChildren(); + } + if ((null != componentChildren) && (componentChildren.size() > 0)) + { + for (int k = 0; k < componentChildren.size(); k++) { - renderChildren(facesContext, writer, tree, child.getChildren(), maxLevel, iconProvider); + RendererUtils.renderChild(facesContext, (UIComponent) componentChildren.get(k)); } } + else + { + child.encodeBegin(facesContext); + child.encodeEnd(facesContext); + } + writer.endElement(HTML.TD_ELEM); } - private void writeImageElement(String url, FacesContext facesContext, ResponseWriter writer, HtmlTreeNode child) - throws IOException + throws IOException { writer.startElement(HTML.IMG_ELEM, child); - String src =facesContext.getApplication().getViewHandler().getResourceURL(facesContext, url); -// if (url.startsWith(HTML.HREF_PATH_SEPARATOR)) -// { -// String path = facesContext.getExternalContext().getRequestContextPath(); -// src = path + url; -// } else -// { -// src = url; -// } -// //Encode URL -// src = facesContext.getExternalContext().encodeResourceURL(src); + String src = facesContext.getApplication().getViewHandler().getResourceURL(facesContext, url); + // if (url.startsWith(HTML.HREF_PATH_SEPARATOR)) + // { + // String path = + // facesContext.getExternalContext().getRequestContextPath(); + // src = path + url; + // } else + // { + // src = url; + // } + // //Encode URL + // src = facesContext.getExternalContext().encodeResourceURL(src); writer.writeAttribute(HTML.SRC_ATTR, src, null); writer.writeAttribute(HTML.BORDER_ATTR, ZERO, null); @@ -274,41 +553,40 @@ writer.endElement(HTML.IMG_ELEM); } - protected String getLayoutImage(HtmlTree tree, int state) { switch (state) { - case HtmlTreeNode.OPEN: - return tree.getIconNodeOpenMiddle(); - case HtmlTreeNode.OPEN_FIRST: - return tree.getIconNodeOpenFirst(); - case HtmlTreeNode.OPEN_LAST: - return tree.getIconNodeOpenLast(); - case HtmlTreeNode.OPEN_SINGLE: - return tree.getIconNodeOpen(); - case HtmlTreeNode.CLOSED: - return tree.getIconNodeCloseMiddle(); - case HtmlTreeNode.CLOSED_FIRST: - return tree.getIconNodeCloseFirst(); - case HtmlTreeNode.CLOSED_LAST: - return tree.getIconNodeCloseLast(); - case HtmlTreeNode.CLOSED_SINGLE: - return tree.getIconNodeClose(); - case HtmlTreeNode.CHILD: - return tree.getIconChildMiddle(); - case HtmlTreeNode.CHILD_FIRST: - return tree.getIconChildFirst(); - case HtmlTreeNode.CHILD_LAST: - return tree.getIconChildLast(); - case HtmlTreeNode.CHILD_SINGLE: - return tree.getIconChild(); - case HtmlTreeNode.LINE: - return tree.getIconLine(); - case HtmlTreeNode.EMPTY: - return tree.getIconNoline(); - default: - return tree.getIconNoline(); + case HtmlTreeNode.OPEN: + return tree.getIconNodeOpenMiddle(); + case HtmlTreeNode.OPEN_FIRST: + return tree.getIconNodeOpenFirst(); + case HtmlTreeNode.OPEN_LAST: + return tree.getIconNodeOpenLast(); + case HtmlTreeNode.OPEN_SINGLE: + return tree.getIconNodeOpen(); + case HtmlTreeNode.CLOSED: + return tree.getIconNodeCloseMiddle(); + case HtmlTreeNode.CLOSED_FIRST: + return tree.getIconNodeCloseFirst(); + case HtmlTreeNode.CLOSED_LAST: + return tree.getIconNodeCloseLast(); + case HtmlTreeNode.CLOSED_SINGLE: + return tree.getIconNodeClose(); + case HtmlTreeNode.CHILD: + return tree.getIconChildMiddle(); + case HtmlTreeNode.CHILD_FIRST: + return tree.getIconChildFirst(); + case HtmlTreeNode.CHILD_LAST: + return tree.getIconChildLast(); + case HtmlTreeNode.CHILD_SINGLE: + return tree.getIconChild(); + case HtmlTreeNode.LINE: + return tree.getIconLine(); + case HtmlTreeNode.EMPTY: + return tree.getIconNoline(); + default: + return tree.getIconNoline(); } } -} +} \ No newline at end of file Index: src/components/org/apache/myfaces/custom/tree/taglib/TreeTag.java =================================================================== RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/tree/taglib/TreeTag.java,v retrieving revision 1.7 diff -u -r1.7 TreeTag.java --- src/components/org/apache/myfaces/custom/tree/taglib/TreeTag.java 13 Oct 2004 11:50:58 -0000 1.7 +++ src/components/org/apache/myfaces/custom/tree/taglib/TreeTag.java 16 Nov 2004 05:28:48 -0000 @@ -26,326 +26,403 @@ import javax.faces.el.ValueBinding; import javax.servlet.jsp.JspException; - /** + ** HtmlTree tag. + *
+ * + * @author Oliver Rossmueller + * @version $Revision: 1.7 $ $Date: 2004/10/13 11:50:58 $ $Log: TreeTag.java,v $ + * Revision 1.7 2004/10/13 11:50:58 matze renamed packages to + * org.apache + * + *+ * Revision 1.7 2004/11/15 20:14:23 David + * Le Strat. Added support for rowClasses, columnClasses, var, headerClass and footerClass. + *
+ * + *+ * Revision 1.6 2004/08/15 15:28:04 o_rossmueller new model listener handling to + * get modified from events which occur outside the scope of a tree request + *
+ * + *+ * Revision 1.5 2004/07/01 21:53:06 mwessendorf ASF switch + *
+ * + *+ * Revision 1.4 2004/05/10 01:24:51 o_rossmueller added iconClass attribute + *
+ * + *+ * Revision 1.3 2004/05/05 00:18:57 o_rossmueller various fixes/modifications in + * model event handling and tree update + *
+ * + *+ * Revision 1.2 2004/04/22 21:59:17 o_rossmueller added expandRoot attribute + *
* - * @author Oliver Rossmueller - * @version $Revision: 1.7 $ $Date: 2004/10/13 11:50:58 $ - * $Log: TreeTag.java,v $ - * Revision 1.7 2004/10/13 11:50:58 matze - * renamed packages to org.apache - * - * Revision 1.6 2004/08/15 15:28:04 o_rossmueller - * new model listener handling to get modified from events which occur outside the scope of a tree request - * - * Revision 1.5 2004/07/01 21:53:06 mwessendorf - * ASF switch - * - * Revision 1.4 2004/05/10 01:24:51 o_rossmueller - * added iconClass attribute - * - * Revision 1.3 2004/05/05 00:18:57 o_rossmueller - * various fixes/modifications in model event handling and tree update - * - * Revision 1.2 2004/04/22 21:59:17 o_rossmueller - * added expandRoot attribute - * - * Revision 1.1 2004/04/22 10:20:25 manolito - * tree component - * + *+ * Revision 1.1 2004/04/22 10:20:25 manolito tree component + *
+ * */ -public class TreeTag - extends UIComponentTagBase +public class TreeTag extends UIComponentTagBase { private String value; + + private String var; + private String iconLine; + private String iconNoline; + private String iconChild; + private String iconChildFirst; + private String iconChildMiddle; + private String iconChildLast; + private String iconNodeOpen; + private String iconNodeOpenFirst; + private String iconNodeOpenMiddle; + private String iconNodeOpenLast; + private String iconNodeClose; + private String iconNodeCloseFirst; + private String iconNodeCloseMiddle; + private String iconNodeCloseLast; + private String styleClass; + + private String rowClasses; + + private String columnClasses; + + private String headerClass; + + private String footerClass; + private String nodeClass; + private String selectedNodeClass; + private String iconClass; + private boolean expandRoot; - private long expireListeners = HtmlTree.DEFAULT_EXPIRE_LISTENERS; + private long expireListeners = HtmlTree.DEFAULT_EXPIRE_LISTENERS; public String getComponentType() { return "org.apache.myfaces.HtmlTree"; } - public String getRendererType() { return "org.apache.myfaces.HtmlTree"; } - public String getValue() { return value; } - public void setValue(String newValue) { value = newValue; } + /** + * @return Returns the var. + */ + public String getVar() + { + return var; + } + + /** + * @param var The var to set. + */ + public void setVar(String var) + { + this.var = var; + } public String getIconLine() { return iconLine; } - public void setIconLine(String iconLine) { this.iconLine = iconLine; } - public String getIconNoline() { return iconNoline; } - public void setIconNoline(String iconNoline) { this.iconNoline = iconNoline; } - public String getIconChild() { return iconChild; } - public void setIconChild(String iconChild) { this.iconChild = iconChild; } + /** + * @return Returns the rowClasses. + */ + public String getRowClasses() + { + return rowClasses; + } + + /** + * @param rowClasses The rowClasses to set. + */ + public void setRowClasses(String rowClasses) + { + this.rowClasses = rowClasses; + } + + /** + * @return Returns the columnClasses. + */ + public String getColumnClasses() + { + return columnClasses; + } + + /** + * @param columnClasses The columnClasses to set. + */ + public void setColumnClasses(String columnClasses) + { + this.columnClasses = columnClasses; + } public String getIconChildFirst() { return iconChildFirst; } - public void setIconChildFirst(String iconChildFirst) { this.iconChildFirst = iconChildFirst; } - public String getIconChildMiddle() { return iconChildMiddle; } - public void setIconChildMiddle(String iconChildMiddle) { this.iconChildMiddle = iconChildMiddle; } - public String getIconChildLast() { return iconChildLast; } - public void setIconChildLast(String iconChildLast) { this.iconChildLast = iconChildLast; } - public String getIconNodeOpen() { return iconNodeOpen; } - public void setIconNodeOpen(String iconNodeOpen) { this.iconNodeOpen = iconNodeOpen; } - public String getIconNodeOpenFirst() { return iconNodeOpenFirst; } - public void setIconNodeOpenFirst(String iconNodeOpenFirst) { this.iconNodeOpenFirst = iconNodeOpenFirst; } - public String getIconNodeOpenMiddle() { return iconNodeOpenMiddle; } - public void setIconNodeOpenMiddle(String iconNodeOpenMiddle) { this.iconNodeOpenMiddle = iconNodeOpenMiddle; } - public String getIconNodeOpenLast() { return iconNodeOpenLast; } - public void setIconNodeOpenLast(String iconNodeOpenLast) { this.iconNodeOpenLast = iconNodeOpenLast; } - public String getIconNodeClose() { return iconNodeClose; } - public void setIconNodeClose(String iconNodeClose) { this.iconNodeClose = iconNodeClose; } - public String getIconNodeCloseFirst() { return iconNodeCloseFirst; } - public void setIconNodeCloseFirst(String iconNodeCloseFirst) { this.iconNodeCloseFirst = iconNodeCloseFirst; } - public String getIconNodeCloseMiddle() { return iconNodeCloseMiddle; } - public void setIconNodeCloseMiddle(String iconNodeCloseMiddle) { this.iconNodeCloseMiddle = iconNodeCloseMiddle; } - public String getIconNodeCloseLast() { return iconNodeCloseLast; } - public void setIconNodeCloseLast(String iconNodeCloseLast) { this.iconNodeCloseLast = iconNodeCloseLast; } - public String getStyleClass() { return styleClass; } - public void setStyleClass(String styleClass) { this.styleClass = styleClass; } - public String getNodeClass() { return nodeClass; } - public void setNodeClass(String nodeClass) { this.nodeClass = nodeClass; } - public String getSelectedNodeClass() { return selectedNodeClass; } - public void setSelectedNodeClass(String selectedNodeClass) { this.selectedNodeClass = selectedNodeClass; } - public String getIconClass() { return iconClass; } - public void setIconClass(String iconClass) { this.iconClass = iconClass; } + /** + * @return Returns the footerClass. + */ + public String getFooterClass() + { + return footerClass; + } + + /** + * @param footerClass The footerClass to set. + */ + public void setFooterClass(String footerClass) + { + this.footerClass = footerClass; + } + + /** + * @return Returns the headerClass. + */ + public String getHeaderClass() + { + return headerClass; + } + + /** + * @param headerClass The headerClass to set. + */ + public void setHeaderClass(String headerClass) + { + this.headerClass = headerClass; + } public boolean isExpandRoot() { return expandRoot; } - public void setExpandRoot(boolean expandRoot) { this.expandRoot = expandRoot; } - public long getExpireListeners() { return expireListeners; } - public void setExpireListeners(long expireListeners) { this.expireListeners = expireListeners; } - /** * Obtain tree model or create a default model. */ @@ -356,7 +433,7 @@ if (value != null) { ValueBinding valueBinding = context.getApplication().createValueBinding(value); - TreeModel treeModel = (TreeModel)(valueBinding.getValue(context)); + TreeModel treeModel = (TreeModel) (valueBinding.getValue(context)); if (treeModel == null) { @@ -373,8 +450,9 @@ // component was created, so expand the root node TreeModel model = tree.getModel(context); - if (model != null) { - tree.expandPath(new TreePath(new Object[]{model.getRoot()}), context); + if (model != null) + { + tree.expandPath(new TreePath(new Object[] { model.getRoot() }), context); } } @@ -382,7 +460,6 @@ return answer; } - /** * Applies attributes to the tree component */ @@ -409,6 +486,7 @@ component.setValueBinding("model", binding); } + setStringProperty(component, "var", var); setStringProperty(component, "iconLine", iconLine); setStringProperty(component, "iconNoline", iconNoline); setStringProperty(component, "iconChild", iconChild); @@ -424,9 +502,13 @@ setStringProperty(component, "iconNodeCloseMiddle", iconNodeCloseMiddle); setStringProperty(component, "iconNodeCloseLast", iconNodeCloseLast); setStringProperty(component, "styleClass", styleClass); + setStringProperty(component, "rowClasses", rowClasses); + setStringProperty(component, "columnClasses", columnClasses); + setStringProperty(component, "headerClass", headerClass); + setStringProperty(component, "footerClass", footerClass); setStringProperty(component, "nodeClass", nodeClass); setStringProperty(component, "selectedNodeClass", selectedNodeClass); setStringProperty(component, "iconClass", iconClass); - ((HtmlTree)component).setExpireListeners(expireListeners); + ((HtmlTree) component).setExpireListeners(expireListeners); } -} +} \ No newline at end of file Index: src/share/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java =================================================================== RCS file: /home/cvs/incubator-myfaces/src/share/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java,v retrieving revision 1.4 diff -u -r1.4 HtmlTableRendererBase.java --- src/share/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java 13 Oct 2004 11:51:01 -0000 1.4 +++ src/share/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java 16 Nov 2004 05:28:51 -0000 @@ -35,42 +35,69 @@ /** * @author Thomas Spiegl (latest modification by $Author: matze $) - * @version $Revision: 1.4 $ $Date: 2004/10/13 11:51:01 $ - * $Log: HtmlTableRendererBase.java,v $ - * Revision 1.4 2004/10/13 11:51:01 matze - * renamed packages to org.apache - * - * Revision 1.3 2004/09/03 14:31:52 manolito - * render header and footer style class with th/rd instead of tr - * - * Revision 1.2 2004/09/02 13:38:02 manolito - * protected methods for easier overwriting of header and footer rendering - * - * Revision 1.1 2004/08/20 07:14:43 manolito - * HtmlDataTable now also supports rowIndexVar and rowCountVar - * - * - * + * @version $Revision: 1.4 $ $Date: 2004/10/13 11:51:01 $ $Log: + * HtmlTableRendererBase.java,v $ Revision 1.4 2004/10/13 11:51:01 + * matze renamed packages to org.apache + * + *+ * Revision 1.4 2004/11/15 20:14:23 David Le Strat + * Support for column header/footer colspan. + *
+ * + *+ * Revision 1.3 2004/09/03 14:31:52 manolito render header and footer style + * class with th/rd instead of tr + *
+ * + *+ * Revision 1.2 2004/09/02 13:38:02 manolito protected methods for easier + * overwriting of header and footer rendering + *
+ * + *+ * Revision 1.1 2004/08/20 07:14:43 manolito HtmlDataTable now also supports + * rowIndexVar and rowCountVar + *
+ * + * + * * old cvs log (HtmlTableRenderer in myfaces impl): - * - * Revision 1.20 2004/08/09 08:01:08 manolito - * bug #1004896 - id attribute not rendered - * - * Revision 1.19 2004/07/01 22:05:06 mwessendorf - * ASF switch - * - * Revision 1.18 2004/06/22 15:26:04 prophecyslides - * headerClass does not apply to the+ * Revision 1.20 2004/08/09 08:01:08 manolito bug #1004896 - id attribute not + * rendered + *
+ * + *+ * Revision 1.19 2004/07/01 22:05:06 mwessendorf ASF switch + *
+ * + *+ * Revision 1.18 2004/06/22 15:26:04 prophecyslides headerClass does not apply + * to the + *
+ * Revision 1.17 2004/06/21 23:12:46 prophecyslides headerClass style propogates + * to the + *
+ * Revision 1.16 2004/06/21 10:57:59 manolito missing CVS Log keyword + *
*/ -public class HtmlTableRendererBase - extends HtmlRenderer +public class HtmlTableRendererBase extends HtmlRenderer { + /** Header facet name. */ + protected static final String HEADER_FACET_NAME = "header"; + + /** Footer facet name. */ + protected static final String FOOTER_FACET_NAME = "footer"; + + /** The logger. */ private static final Log log = LogFactory.getLog(HtmlTableRendererBase.class); public boolean getRendersChildren() @@ -84,21 +111,21 @@ ResponseWriter writer = facesContext.getResponseWriter(); - beforeTable(facesContext, (UIData)uiComponent); + beforeTable(facesContext, (UIData) uiComponent); HtmlRendererUtils.writePrettyLineSeparator(facesContext); writer.startElement(HTML.TABLE_ELEM, uiComponent); writer.writeAttribute(HTML.ID_ATTR, uiComponent.getClientId(facesContext), null); HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TABLE_PASSTHROUGH_ATTRIBUTES); - renderFacet(facesContext, writer, (UIData)uiComponent, true); + renderFacet(facesContext, writer, (UIData) uiComponent, true); } public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException { RendererUtils.checkParamValidity(facesContext, component, UIData.class); - UIData uiData = (UIData)component; + UIData uiData = (UIData) component; ResponseWriter writer = facesContext.getResponseWriter(); @@ -109,13 +136,13 @@ String columnClasses; if (component instanceof HtmlDataTable) { - rowClasses = ((HtmlDataTable)component).getRowClasses(); - columnClasses = ((HtmlDataTable)component).getColumnClasses(); + rowClasses = ((HtmlDataTable) component).getRowClasses(); + columnClasses = ((HtmlDataTable) component).getColumnClasses(); } else { - rowClasses = (String)component.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR); - columnClasses = (String)component.getAttributes().get(JSFAttr.COLUMN_CLASSES_ATTR); + rowClasses = (String) component.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR); + columnClasses = (String) component.getAttributes().get(JSFAttr.COLUMN_CLASSES_ATTR); } Styles styles = new Styles(rowClasses, columnClasses); @@ -127,7 +154,8 @@ rows = rowCount - first; } int last = first + rows; - if (last > rowCount) last = rowCount; + if (last > rowCount) + last = rowCount; for (int i = first; i < last; i++) { @@ -151,8 +179,8 @@ List children = component.getChildren(); for (int j = 0, size = component.getChildCount(); j < size; j++) { - UIComponent child = (UIComponent)children.get(j); - if (child instanceof UIColumn && ((UIColumn)child).isRendered()) + UIComponent child = (UIComponent) children.get(j); + if (child instanceof UIColumn && ((UIColumn) child).isRendered()) { writer.startElement(HTML.TD_ELEM, component); if (styles.hasColumnStyle()) @@ -171,7 +199,6 @@ writer.endElement(HTML.TBODY_ELEM); } - /** * Convenient method for derived table renderers. */ @@ -205,129 +232,93 @@ RendererUtils.checkParamValidity(facesContext, uiComponent, UIData.class); ResponseWriter writer = facesContext.getResponseWriter(); - renderFacet(facesContext, writer, (UIData)uiComponent, false); + renderFacet(facesContext, writer, (UIData) uiComponent, false); writer.endElement(HTML.TABLE_ELEM); HtmlRendererUtils.writePrettyLineSeparator(facesContext); - afterTable(facesContext, (UIData)uiComponent); + afterTable(facesContext, (UIData) uiComponent); } - - private void renderFacet(FacesContext facesContext, - ResponseWriter writer, - UIData uiData, - boolean header) throws IOException + protected void renderFacet(FacesContext facesContext, ResponseWriter writer, UIComponent component, boolean header) + throws IOException { int colspan = 0; boolean hasColumnFacet = false; - for (Iterator it = uiData.getChildren().iterator(); it.hasNext(); ) + for (Iterator it = component.getChildren().iterator(); it.hasNext();) { - UIComponent uiComponent = (UIComponent)it.next(); - if (uiComponent instanceof UIColumn && - ((UIColumn)uiComponent).isRendered()) + UIComponent uiComponent = (UIComponent) it.next(); + if (uiComponent instanceof UIColumn && ((UIColumn) uiComponent).isRendered()) { colspan++; if (!hasColumnFacet) { - hasColumnFacet = header ? ((UIColumn)uiComponent).getHeader() != null : - ((UIColumn)uiComponent).getFooter() != null; + hasColumnFacet = header ? ((UIColumn) uiComponent).getHeader() != null : ((UIColumn) uiComponent) + .getFooter() != null; } } } - UIComponent facet = header ? uiData.getHeader() : uiData.getFooter(); + UIComponent facet = header ? (UIComponent) component.getFacets().get(HEADER_FACET_NAME) + : (UIComponent) component.getFacets().get(FOOTER_FACET_NAME); if (facet != null || hasColumnFacet) { // Header or Footer present String elemName = header ? HTML.THEAD_ELEM : HTML.TFOOT_ELEM; HtmlRendererUtils.writePrettyLineSeparator(facesContext); - writer.startElement(elemName, uiData); + writer.startElement(elemName, component); if (header) { - String headerStyleClass = getHeaderClass(uiData); - if (facet != null) renderTableHeaderRow(facesContext, writer, uiData, facet, headerStyleClass, colspan); - if (hasColumnFacet) renderColumnHeaderRow(facesContext, writer, uiData, headerStyleClass); + String headerStyleClass = getHeaderClass(component); + if (facet != null) + renderTableHeaderRow(facesContext, writer, component, facet, headerStyleClass, colspan); + if (hasColumnFacet) + renderColumnHeaderRow(facesContext, writer, component, headerStyleClass); } else { - String footerStyleClass = getFooterClass(uiData); - if (hasColumnFacet) renderColumnFooterRow(facesContext, writer, uiData, footerStyleClass); - if (facet != null) renderTableFooterRow(facesContext, writer, uiData, facet, footerStyleClass, colspan); + String footerStyleClass = getFooterClass(component); + if (hasColumnFacet) + renderColumnFooterRow(facesContext, writer, component, footerStyleClass); + if (facet != null) + renderTableFooterRow(facesContext, writer, component, facet, footerStyleClass, colspan); } writer.endElement(elemName); } } - - protected void renderTableHeaderRow(FacesContext facesContext, - ResponseWriter writer, - UIData uiData, - UIComponent headerFacet, - String headerStyleClass, - int colspan) - throws IOException - { - renderTableHeaderOrFooterRow(facesContext, - writer, - uiData, - headerFacet, - headerStyleClass, - HTML.TH_ELEM, - colspan); - } - - protected void renderTableFooterRow(FacesContext facesContext, - ResponseWriter writer, - UIData uiData, - UIComponent footerFacet, - String footerStyleClass, - int colspan) - throws IOException - { - renderTableHeaderOrFooterRow(facesContext, - writer, - uiData, - footerFacet, - footerStyleClass, - HTML.TD_ELEM, - colspan); - } - - - protected void renderColumnHeaderRow(FacesContext facesContext, - ResponseWriter writer, - UIData uiData, - String headerStyleClass) - throws IOException - { - renderColumnHeaderOrFooterRow(facesContext, writer, uiData, headerStyleClass, true); - } - - protected void renderColumnFooterRow(FacesContext facesContext, - ResponseWriter writer, - UIData uiData, - String footerStyleClass) - throws IOException - { - renderColumnHeaderOrFooterRow(facesContext, writer, uiData, footerStyleClass, false); + protected void renderTableHeaderRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + UIComponent headerFacet, String headerStyleClass, int colspan) throws IOException + { + renderTableHeaderOrFooterRow(facesContext, writer, component, headerFacet, headerStyleClass, HTML.TH_ELEM, + colspan); } + protected void renderTableFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + UIComponent footerFacet, String footerStyleClass, int colspan) throws IOException + { + renderTableHeaderOrFooterRow(facesContext, writer, component, footerFacet, footerStyleClass, HTML.TD_ELEM, + colspan); + } + protected void renderColumnHeaderRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + String headerStyleClass) throws IOException + { + renderColumnHeaderOrFooterRow(facesContext, writer, component, headerStyleClass, true); + } + protected void renderColumnFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + String footerStyleClass) throws IOException + { + renderColumnHeaderOrFooterRow(facesContext, writer, component, footerStyleClass, false); + } - private void renderTableHeaderOrFooterRow(FacesContext facesContext, - ResponseWriter writer, - UIData uiData, - UIComponent facet, - String styleClass, - String colElementName, - int colspan) - throws IOException + private void renderTableHeaderOrFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + UIComponent facet, String styleClass, String colElementName, int colspan) throws IOException { HtmlRendererUtils.writePrettyLineSeparator(facesContext); - writer.startElement(HTML.TR_ELEM, uiData); - writer.startElement(colElementName, uiData); + writer.startElement(HTML.TR_ELEM, component); + writer.startElement(colElementName, component); if (colElementName.equals(HTML.TH_ELEM)) { writer.writeAttribute(HTML.SCOPE_ATTR, HTML.SCOPE_COLGROUP_VALUE, null); @@ -345,53 +336,40 @@ writer.endElement(HTML.TR_ELEM); } - - - private void renderColumnHeaderOrFooterRow(FacesContext facesContext, - ResponseWriter writer, - UIData uiData, - String styleClass, - boolean header) - throws IOException + private void renderColumnHeaderOrFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component, + String styleClass, boolean header) throws IOException { HtmlRendererUtils.writePrettyLineSeparator(facesContext); - writer.startElement(HTML.TR_ELEM, uiData); - for (Iterator it = uiData.getChildren().iterator(); it.hasNext(); ) + writer.startElement(HTML.TR_ELEM, component); + for (Iterator it = component.getChildren().iterator(); it.hasNext();) { - UIComponent uiComponent = (UIComponent)it.next(); - if (uiComponent instanceof UIColumn && - ((UIColumn)uiComponent).isRendered()) + UIComponent uiComponent = (UIComponent) it.next(); + if (uiComponent instanceof UIColumn && ((UIColumn) uiComponent).isRendered()) { if (header) { - renderColumnHeaderCell(facesContext, - writer, - (UIColumn)uiComponent, - styleClass); + renderColumnHeaderCell(facesContext, writer, (UIColumn) uiComponent, styleClass, 0); } else { - renderColumnFooterCell(facesContext, - writer, - (UIColumn)uiComponent, - styleClass); + renderColumnFooterCell(facesContext, writer, (UIColumn) uiComponent, styleClass, 0); } } } writer.endElement(HTML.TR_ELEM); } - - protected void renderColumnHeaderCell(FacesContext facesContext, - ResponseWriter writer, - UIColumn uiColumn, - String headerStyleClass) - throws IOException + protected void renderColumnHeaderCell(FacesContext facesContext, ResponseWriter writer, UIColumn uiColumn, + String headerStyleClass, int colspan) throws IOException { writer.startElement(HTML.TH_ELEM, uiColumn); + if (colspan > 1) + { + writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(colspan), null); + } if (headerStyleClass != null) { - writer.writeAttribute(HTML.CLASS_ATTR, headerStyleClass, null); + writer.writeAttribute(HTML.CLASS_ATTR, headerStyleClass, null); } UIComponent facet = uiColumn.getHeader(); if (facet != null) @@ -401,16 +379,17 @@ writer.endElement(HTML.TH_ELEM); } - protected void renderColumnFooterCell(FacesContext facesContext, - ResponseWriter writer, - UIColumn uiColumn, - String footerStyleClass) - throws IOException + protected void renderColumnFooterCell(FacesContext facesContext, ResponseWriter writer, UIColumn uiColumn, + String footerStyleClass, int colspan) throws IOException { writer.startElement(HTML.TD_ELEM, uiColumn); + if (colspan > 1) + { + writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(colspan), null); + } if (footerStyleClass != null) { - writer.writeAttribute(HTML.CLASS_ATTR, footerStyleClass, null); + writer.writeAttribute(HTML.CLASS_ATTR, footerStyleClass, null); } UIComponent facet = uiColumn.getFooter(); if (facet != null) @@ -420,54 +399,50 @@ writer.endElement(HTML.TD_ELEM); } - - private static String getHeaderClass(UIData component) + protected static String getHeaderClass(UIComponent component) { if (component instanceof HtmlDataTable) { - return ((HtmlDataTable)component).getHeaderClass(); + return ((HtmlDataTable) component).getHeaderClass(); } else { - return (String)component.getAttributes().get(JSFAttr.HEADER_CLASS_ATTR); + return (String) component.getAttributes().get(JSFAttr.HEADER_CLASS_ATTR); } } - private static String getFooterClass(UIData component) + protected static String getFooterClass(UIComponent component) { if (component instanceof HtmlDataTable) { - return ((HtmlDataTable)component).getFooterClass(); + return ((HtmlDataTable) component).getFooterClass(); } else { - return (String)component.getAttributes().get(JSFAttr.FOOTER_CLASS_ATTR); + return (String) component.getAttributes().get(JSFAttr.FOOTER_CLASS_ATTR); } } - //------------------------------------------------------------- // Helper class Styles //------------------------------------------------------------- private static class Styles { - //~ Instance fields ------------------------------------------------------------------------ + //~ Instance fields + // ------------------------------------------------------------------------ private String[] _columnStyle; - private String[] _rowStyle; - //~ Constructors --------------------------------------------------------------------------- + private String[] _rowStyle; + //~ Constructors + // --------------------------------------------------------------------------- Styles(String rowStyles, String columnStyles) { - _rowStyle = (rowStyles == null) - ? ArrayUtils.EMPTY_STRING_ARRAY - : StringUtils.trim( - StringUtils.splitShortString(rowStyles, ',')); - _columnStyle = (columnStyles == null) - ? ArrayUtils.EMPTY_STRING_ARRAY - : StringUtils.trim( - StringUtils.splitShortString(columnStyles, ',')); + _rowStyle = (rowStyles == null) ? ArrayUtils.EMPTY_STRING_ARRAY : StringUtils.trim(StringUtils + .splitShortString(rowStyles, ',')); + _columnStyle = (columnStyles == null) ? ArrayUtils.EMPTY_STRING_ARRAY : StringUtils.trim(StringUtils + .splitShortString(columnStyles, ',')); } public String getRowStyle(int idx) @@ -500,5 +475,4 @@ } - -} +} \ No newline at end of file Index: tlds/myfaces_ext.tld =================================================================== RCS file: /home/cvs/incubator-myfaces/tlds/myfaces_ext.tld,v retrieving revision 1.122 diff -u -r1.122 myfaces_ext.tld --- tlds/myfaces_ext.tld 8 Nov 2004 20:43:15 -0000 1.122 +++ tlds/myfaces_ext.tld 16 Nov 2004 05:28:55 -0000 @@ -1235,6 +1235,11 @@+ * Tree column model. This column is used to provide the place holder for the + * tree. This is used in conjunction with the table format display. + *
+ * @author David Le Strat + */ +public class HtmlTreeColumn extends UIColumn +{ + /** The component type. */ + public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlTreeColumn"; + + /** The component family. */ + public static final String COMPONENT_FAMILY = "org.apache.myfaces.HtmlTreeColumn"; + + /** + *+ * Default Constructor. + *
+ */ + public HtmlTreeColumn() + { + super(); + } + + /** + * @see javax.faces.component.UIComponent#getFamily() + */ + public String getFamily() + { + return COMPONENT_FAMILY; + } +} Index: src/components/org/apache/myfaces/custom/tree/HtmlTreeColumn.xml =================================================================== RCS file: src/components/org/apache/myfaces/custom/tree/HtmlTreeColumn.xml diff -N src/components/org/apache/myfaces/custom/tree/HtmlTreeColumn.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/components/org/apache/myfaces/custom/tree/HtmlTreeColumn.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ + + ++ * Tag used to render the column containing the tree. + *
+ * + * @author David Le Strat + */ +public class TreeColumnTag extends HtmlComponentBodyTagBase +{ + + /** + * @see javax.faces.webapp.UIComponentTag#getComponentType() + */ + public String getComponentType() + { + return HtmlTreeColumn.COMPONENT_TYPE; + } + + /** + * @see javax.faces.webapp.UIComponentTag#getRendererType() + */ + public String getRendererType() + { + return null; + } + + // UIComponent attributes --> already implemented in UIComponentTagBase +} Index: webapps/examples/src/org/apache/myfaces/examples/listexample/TreeItem.java =================================================================== RCS file: webapps/examples/src/org/apache/myfaces/examples/listexample/TreeItem.java diff -N webapps/examples/src/org/apache/myfaces/examples/listexample/TreeItem.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ webapps/examples/src/org/apache/myfaces/examples/listexample/TreeItem.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,115 @@ +/* + * Copyright 2004 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.myfaces.examples.listexample; + +import java.io.Serializable; + +/** + *+ * Bean class holding a tree item. + *
+ * + * @author David Le Strat + * */ +public class TreeItem implements Serializable +{ + private int id; + + private String name; + + private String isoCode; + + private String description; + + + /** + * @param id The id. + * @param name The name. + * @param isoCode The isoCode. + * @param description The description. + */ + public TreeItem(int id, String name, String isoCode, String description) + { + this.id = id; + this.name = name; + this.isoCode = isoCode; + this.description = description; + } + + /** + * @return Returns the description. + */ + public String getDescription() + { + return description; + } + + /** + * @param description The description to set. + */ + public void setDescription(String description) + { + this.description = description; + } + + /** + * @return Returns the id. + */ + public int getId() + { + return id; + } + + /** + * @param id The id to set. + */ + public void setId(int id) + { + this.id = id; + } + + /** + * @return Returns the isoCode. + */ + public String getIsoCode() + { + return isoCode; + } + + /** + * @param isoCode The isoCode to set. + */ + public void setIsoCode(String isoCode) + { + this.isoCode = isoCode; + } + + /** + * @return Returns the name. + */ + public String getName() + { + return name; + } + + /** + * @param name The name to set. + */ + public void setName(String name) + { + this.name = name; + } +} Index: webapps/examples/src/org/apache/myfaces/examples/listexample/TreeTable.java =================================================================== RCS file: webapps/examples/src/org/apache/myfaces/examples/listexample/TreeTable.java diff -N webapps/examples/src/org/apache/myfaces/examples/listexample/TreeTable.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ webapps/examples/src/org/apache/myfaces/examples/listexample/TreeTable.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,90 @@ +/* + * Copyright 2004 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.myfaces.examples.listexample; + +import java.io.Serializable; + +import org.apache.myfaces.custom.tree.DefaultMutableTreeNode; +import org.apache.myfaces.custom.tree.model.DefaultTreeModel; + +/** + *+ * Bean holding the tree hierarchy. + *
+ * + * @author David Le Strat + */ +public class TreeTable implements Serializable +{ + private DefaultTreeModel treeModel; + + /** + * @param treeModel The treeModel. + */ + public TreeTable(DefaultTreeModel treeModel) + { + this.treeModel = treeModel; + } + + /** + *+ * Default constructor. + *
+ */ + public TreeTable() + { + DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TreeItem(1, "XY", "9001", "XY 9001")); + DefaultMutableTreeNode a = new DefaultMutableTreeNode(new TreeItem(2, "A", "9001", "A 9001")); + root.insert(a); + DefaultMutableTreeNode b = new DefaultMutableTreeNode(new TreeItem(3, "B", "9001", "B 9001")); + root.insert(b); + DefaultMutableTreeNode c = new DefaultMutableTreeNode(new TreeItem(4, "C", "9001", "C 9001")); + root.insert(c); + + DefaultMutableTreeNode node = new DefaultMutableTreeNode(new TreeItem(5, "a1", "9002", "a1 9002")); + a.insert(node); + node = new DefaultMutableTreeNode(new TreeItem(6, "a2", "9002", "a2 9002")); + a.insert(node); + node = new DefaultMutableTreeNode(new TreeItem(7, "a3", "9002", "a3 9002")); + a.insert(node); + node = new DefaultMutableTreeNode(new TreeItem(8, "b", "9002", "b 9002")); + b.insert(node); + + a = node; + node = new DefaultMutableTreeNode(new TreeItem(9, "x1", "9003", "x1 9003")); + a.insert(node); + node = new DefaultMutableTreeNode(new TreeItem(9, "x2", "9003", "x2 9003")); + a.insert(node); + + this.treeModel = new DefaultTreeModel(root); + } + + /** + * @return Returns the treeModel. + */ + public DefaultTreeModel getTreeModel() + { + return treeModel; + } + + /** + * @param treeModel The treeModel to set. + */ + public void setTreeModel(DefaultTreeModel treeModel) + { + this.treeModel = treeModel; + } +} Index: webapps/examples/web/treeTable.jsp =================================================================== RCS file: webapps/examples/web/treeTable.jsp diff -N webapps/examples/web/treeTable.jsp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ webapps/examples/web/treeTable.jsp 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,106 @@ +<%@ page session="true" contentType="text/html;charset=utf-8"%> +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> +<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%> + + + + +<%@include file="inc/head.inc" %> + + + + + + +