You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2006/11/17 16:32:09 UTC

svn commit: r476178 - in /myfaces/tobago/trunk: example/sandbox/src/main/webapp/ example/sandbox/src/main/webapp/WEB-INF/ sandbox/src/main/java/org/apache/myfaces/tobago/component/ sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarboro...

Author: lofwyr
Date: Fri Nov 17 07:32:08 2006
New Revision: 476178

URL: http://svn.apache.org/viewvc?view=rev&rev=476178
Log:
working on TOBAGO-18

Modified:
    myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree.jsp
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTag.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTagDeclaration.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldNodeRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tree.js
    myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/button.jsp
    myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/sheet.jsp

Modified: myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/WEB-INF/faces-config.xml Fri Nov 17 07:32:08 2006
@@ -29,4 +29,10 @@
     </locale-config>
   </application>
 
+  <managed-bean>
+    <managed-bean-name>controller</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.tobago.example.sandbox.Controller</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+
 </faces-config>

Modified: myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree.jsp?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree.jsp (original)
+++ myfaces/tobago/trunk/example/sandbox/src/main/webapp/tree.jsp Fri Nov 17 07:32:08 2006
@@ -67,16 +67,19 @@
               showRoot="true"
               mode="menu">
       <tcs:treeNode label="Root">
+<%--
         <tcs:treeNodes value="#{tree}" var="node">
-          <tcs:treeNode label="#{node.userObject}"/>
+          <tcs:treeNode label="#{node.userObject}"
+                        action="#{controller.action1}"/>
         </tcs:treeNodes>
-        <tcs:treeNode label="Sub 1"/>
-        <tcs:treeNode label="Sub 2"/>
-        <tcs:treeNode label="Sub 3">
-          <tcs:treeNode label="Sub 3.1"/>
-          <tcs:treeNode label="Sub 3.2"/>
+--%>
+        <tcs:treeNode label="Action 1" action="#{controller.action1}"/>
+        <tcs:treeNode label="Action 2" action="#{controller.action2}"/>
+        <tcs:treeNode label="Action 3" action="#{controller.action3}">
+          <tcs:treeNode label="On Click 1" onclick="alert('On Click 1');"/>
+          <tcs:treeNode label="On Click 2" onclick="alert('On Click 2');"/>
         </tcs:treeNode>
-        <tcs:treeNode label="Sub 4"/>
+        <tcs:treeNode label="Link" link="http://myfaces.apache.org/tobago/"/>
       </tcs:treeNode>
     </tcs:tree>
 
@@ -87,9 +90,11 @@
               showRoot="true"
               selectable="single">
       <tcs:treeNode label="Root">
+<%--
         <tcs:treeNodes value="#{tree}" var="node">
           <tcs:treeNode label="#{node.userObject}"/>
         </tcs:treeNodes>
+--%>
         <tcs:treeNode label="Sub 1"/>
         <tcs:treeNode label="Sub 2"/>
         <tcs:treeNode label="Sub 3">

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITree.java Fri Nov 17 07:32:08 2006
@@ -266,22 +266,6 @@
 //     will be called from end.jsp
   }
 
-  public UITreeNode findUITreeNode(UITreeNode node, TreeNode treeNode) {
-    UITreeNode found = null;
-    if (node.getTreeNode().equals(treeNode)) {
-      return node;
-    } else {
-      for (Iterator iter = node.getChildren().iterator(); iter.hasNext();) {
-        UITreeNode uiTreeNode = (UITreeNode) iter.next();
-        found = findUITreeNode(uiTreeNode, treeNode);
-        if (found != null) {
-          break;
-        }
-      }
-    }
-    return found;
-  }
-
   public boolean getRendersChildren() {
     return true;
   }

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java Fri Nov 17 07:32:08 2006
@@ -17,138 +17,12 @@
  * limitations under the License.
  */
 
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeNode;
-
-public class UITreeNode extends UIInput {
-
-  private static final Log LOG = LogFactory.getLog(UITreeNode.class);
+public class UITreeNode extends UICommand {
 
   public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TreeNode";
 
-  private static final String SUB_REFERENCE_KEY = "subReferenceKey";
-
-  private String nodeId;
-
-  private String parentNodeId;
-
-  // todo: use an abstraction for DefaultMutableTreeNode like DataModel for UIData
-  private DefaultMutableTreeNode currentNode;
-
-// ///////////////////////////////////////////// code
-
   @Override
   public boolean getRendersChildren() {
     return true;
   }
-
-  // todo: may be removed
-  public String getSubReference() {
-    return (String) getAttributes().get(SUB_REFERENCE_KEY);
-  }
-
-  public DefaultMutableTreeNode getTreeNode() {
-    return (DefaultMutableTreeNode) getValue();
-  }
-
-  @Override
-  public Object getValue() {
-    TreeNode value = null;
-    UITreeNodes root = findTreeNodesRoot();
-    if (root == null) {
-      return null;
-    }
-    String subReference = getSubReference();
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("root         = '" + root + "'");
-      LOG.debug("subReference = '" + subReference + "'");
-    }
-    TreeNode rootNode = (TreeNode) root.getValue();
-
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("rootNode = '" + rootNode + "'");
-    }
-    if (rootNode != null) {
-      try {
-        if (subReference == null) {
-          value = rootNode;
-        } else {
-          value = (TreeNode) PropertyUtils.getProperty(rootNode, subReference);
-        }
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("treeNode     = '" + value + "'");
-        }
-      } catch (Throwable e) {
-        LOG.error("subReference = '" + subReference + "'", e);
-      }
-    }
-    return value;
-  }
-
-  public UITree findTreeRoot() {
-    UIComponent ancestor = getParent();
-    while (ancestor != null
-        && (ancestor instanceof UITreeNode || ancestor instanceof UITreeNodes)) {
-      ancestor = ancestor.getParent();
-    }
-    if (ancestor instanceof UITree) {
-      return (UITree) ancestor;
-    }
-    return null;
-  }
-
-  public UITreeNodes findTreeNodesRoot() {
-    UIComponent ancestor = getParent();
-    while (ancestor != null && ancestor instanceof UITreeNode) {
-      ancestor = ancestor.getParent();
-    }
-    if (ancestor instanceof UITreeNodes) {
-      return (UITreeNodes) ancestor;
-    }
-    return null;
-  }
-
-  public void updateModel(FacesContext facesContext) {
-    // nothig to update for treeNode's
-  }
-
-  public boolean isFolder() {
-    if (currentNode != null) {
-      return currentNode.getChildCount() > 0;
-    } else {
-      return getChildCount() > 0;
-    }
-  }
-
-  public String getNodeId() {
-    return nodeId;
-  }
-
-  public void setNodeId(String nodeId) {
-    this.nodeId = nodeId;
-  }
-
-  public String getParentNodeId() {
-    return parentNodeId;
-  }
-
-  public void setParentNodeId(String parentNodeId) {
-    this.parentNodeId = parentNodeId;
-  }
-
-  public DefaultMutableTreeNode getCurrentNode() {
-    return currentNode;
-  }
-
-  public void setCurrentNode(DefaultMutableTreeNode currentNode) {
-    this.currentNode = currentNode;
-  }
 }
-

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/component/UITreeNodes.java Fri Nov 17 07:32:08 2006
@@ -21,12 +21,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.renderkit.RenderUtil;
 
-import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.swing.tree.TreeNode;
 import javax.swing.tree.DefaultMutableTreeNode;
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.Enumeration;
 
 public class UITreeNodes extends javax.faces.component.UIInput {
@@ -37,58 +34,24 @@
 
   private String var;
 
-/*
-  public void encodeBegin(FacesContext facesContext)
-      throws IOException {
-    recreateTreeNodes();
-    super.encodeBegin(facesContext);
-  }
+  private DefaultMutableTreeNode currentNode;
 
-  private void recreateTreeNodes() {
-    UITreeNode root = getRoot();
-    // Delete all UIComponent childs, because moving of childen will not work
-    // in Mutable Tree.
-    // They may have invalid modelReferences.
-    try {
-      if (root != null) {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("removing root 1");
-        }
-        getChildren().remove(root);
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("removing root 2");
-        }
-      }
-    } catch (Exception e) {
-      LOG.error("", e);
-    }
+  private String currentNodeId;
 
-    try {
-      root = new UITreeNode(this, 0);
-      root.createTreeNodes();
-    } catch (Exception e) {
-      LOG.error(e, e);
-    }
-  }
-*/
+  private String currentParentNodeId;
 
-  public UITreeNode getRoot() {
-    // find the UITreeNode in the childen.
-    for (Iterator i = getChildren().iterator(); i.hasNext();) {
-      UIComponent child = (UIComponent) i.next();
-      if (child instanceof UITreeNode) {
-        return (UITreeNode) child;
-      }
-    }
-    // in a new UITree isn't a root
-    return null;
+
+  @Override
+  public void decode(FacesContext context) {
+    super.decode(context);
   }
 
+  @Override
   public void encodeChildren(FacesContext context)
       throws IOException {
   }
 
-
+  @Override
   public void encodeEnd(FacesContext facesContext) throws IOException {
 
     DefaultMutableTreeNode tree = (DefaultMutableTreeNode) getValue();
@@ -106,16 +69,21 @@
       return;
     }
 
-    UITreeNode template = getTemplateComponent();
-    template.setParentNodeId(position);
+    currentParentNodeId = position;
     position += ":" + index;
-    template.setNodeId(position);
+    currentNodeId = position;
 
-    facesContext.getExternalContext().getRequestMap().put(var, node);
-    template.setCurrentNode(node);
-    RenderUtil.encode(facesContext, template);
+    currentNode = node;
+    if (var == null) {
+      LOG.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+      LOG.error("var not set");
+      LOG.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+      var = "node";
+    }
+    facesContext.getExternalContext().getRequestMap().put(var, currentNode);
+    RenderUtil.encode(facesContext, getTemplateComponent());
     facesContext.getExternalContext().getRequestMap().remove(var);
-    template.setCurrentNode(null);
+    currentNode = null;
 
     index = 0;
     for (Enumeration e = node.children(); e.hasMoreElements();) {
@@ -125,39 +93,14 @@
     }
   }
 
-  public UITreeNode findUITreeNode(UITreeNode node, TreeNode treeNode) {
-    UITreeNode found = null;
-    if (node.getTreeNode().equals(treeNode)) {
-      return node;
-    } else {
-      for (Iterator iter = node.getChildren().iterator(); iter.hasNext();) {
-        UITreeNode uiTreeNode = (UITreeNode) iter.next();
-        found = findUITreeNode(uiTreeNode, treeNode);
-        if (found != null) {
-          break;
-        }
-      }
-    }
-    return found;
-  }
-
   public boolean getRendersChildren() {
     return true;
   }
 
   public void processDecodes(FacesContext facesContext) {
-    if (ComponentUtil.isOutputOnly(this)) {
-      setValid(true);
-    } else {
-      // in tree first decode node and than decode children
-
-      decode(facesContext);
-
-      for (Iterator i = getFacetsAndChildren(); i.hasNext();) {
-        UIComponent uiComponent = ((UIComponent) i.next());
-        uiComponent.processDecodes(facesContext);
-      }
-    }
+    LOG.info("processDecodes for nodes");
+    LOG.warn("todo"); // todo
+    super.processDecodes(facesContext);
   }
 
   public void updateModel(FacesContext facesContext) {
@@ -174,6 +117,20 @@
     return null;
   }
 
+  @Override
+  public Object saveState(FacesContext context) {
+    Object[] state = new Object[2];
+    state[0] = super.saveState(context);
+    state[1] = var;
+    return state;
+  }
+
+  @Override
+  public void restoreState(FacesContext context, Object state) {
+    Object[] values = (Object[]) state;
+    super.restoreState(context, values[0]);
+    var = (String) values[1];
+  }
 
   public String getVar() {
     return var;
@@ -181,5 +138,29 @@
 
   public void setVar(String var) {
     this.var = var;
+  }
+
+  public DefaultMutableTreeNode getCurrentNode() {
+    return currentNode;
+  }
+
+  public void setCurrentNode(DefaultMutableTreeNode currentNode) {
+    this.currentNode = currentNode;
+  }
+
+  public String getCurrentNodeId() {
+    return currentNodeId;
+  }
+
+  public void setCurrentNodeId(String currentNodeId) {
+    this.currentNodeId = currentNodeId;
+  }
+
+  public String getCurrentParentNodeId() {
+    return currentParentNodeId;
+  }
+
+  public void setCurrentParentNodeId(String currentParentNodeId) {
+    this.currentParentNodeId = currentParentNodeId;
   }
 }

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java Fri Nov 17 07:32:08 2006
@@ -25,16 +25,18 @@
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ACTION_LINK;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MUTABLE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ONCLICK;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MUTABLE;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTABLE;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UITree;
 import org.apache.myfaces.tobago.component.UITreeNode;
 import org.apache.myfaces.tobago.component.UITreeNodes;
 import org.apache.myfaces.tobago.model.TreeState;
-import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
 
 import javax.faces.component.NamingContainer;
 import javax.faces.component.UICommand;
@@ -48,21 +50,25 @@
 import java.io.IOException;
 import java.util.Map;
 
-public class TreeNodeRenderer extends RendererBase {
+public class TreeNodeRenderer extends CommandRendererBase {
 
   private static final Log LOG = LogFactory.getLog(TreeNodeRenderer.class);
 
+  @Override
   public void decode(FacesContext facesContext, UIComponent component) {
+
+    super.decode(facesContext, component);
+
     if (ComponentUtil.isOutputOnly(component)) {
       return;
     }
 
     UITreeNode node = (UITreeNode) component;
-    UITree tree = node.findTreeRoot();
+    UITree tree = findTree(node);
     TreeState state = tree.getState();
     String treeId = tree.getClientId(facesContext);
     String nodeId = node.getId();
-    final Map requestParameterMap
+    Map requestParameterMap
         = facesContext.getExternalContext().getRequestParameterMap();
 
     // expand state
@@ -127,7 +133,7 @@
       }
     }
 
-    node.setValid(true);
+//    node.setValid(true);
   }
 
   private UIParameter ensureTreeNodeParameter(UICommand command) {
@@ -148,32 +154,42 @@
     return treeNodeParameter;
   }
 
-  public void encodeBegin(FacesContext facesContext,
-                                UIComponent component) throws IOException {
+  @Override
+  public void encodeBegin(FacesContext facesContext, UIComponent component)
+      throws IOException {
 
     UITreeNode treeNode = (UITreeNode) component;
 
-    String clientId = treeNode.getClientId(facesContext);
-    String pos = treeNode.getNodeId();
-    clientId += pos != null ? pos : "";
     UIComponent parent = treeNode.getParent();
+    String pos = null;
+
+    boolean isFolder = treeNode.getChildCount() > 0;
 
     String parentClientId = null;
     if (parent != null && parent instanceof UITreeNode) { // if not the root node
       parentClientId = treeNode.getParent().getClientId(facesContext);
     } else if (parent != null && parent instanceof UITreeNodes) {
-      if (pos.equals(":0")) {
-        UIComponent superParent = treeNode.getParent().getParent();
+      pos = ((UITreeNodes)parent).getCurrentNodeId();
+      if (":0".equals(pos)) {
+        UIComponent superParent = parent.getParent();
         parentClientId = superParent.getClientId(facesContext);
       } else {
         parentClientId = treeNode.getClientId(facesContext);
-        parentClientId += treeNode.getParentNodeId();
+        parentClientId += ((UITreeNodes)parent).getCurrentParentNodeId();
+      }
+      DefaultMutableTreeNode currentNode =
+          ((UITreeNodes) parent).getCurrentNode();
+      if (currentNode != null) {
+        isFolder = currentNode.getChildCount() > 0;
       }
     }
 
-    UITree root = treeNode.findTreeRoot();
+    UITree root = findTree(treeNode);
     String rootId = root.getClientId(facesContext);
 
+    String clientId = treeNode.getClientId(facesContext);
+    clientId += pos != null ? pos : "";
+
     String jsClientId = TreeRenderer.createJavascriptVariable(clientId);
     String jsParentClientId = TreeRenderer.createJavascriptVariable(
         parentClientId);
@@ -215,7 +231,7 @@
       writer.writeText("',", null);
 
       // is folder
-      writer.writeText(treeNode.isFolder(), null);
+      writer.writeText(isFolder, null);
       writer.writeText(",", null);
       writer.writeText(Boolean.toString(!root.isShowIcons()), null);
       writer.writeText(",", null);
@@ -281,14 +297,34 @@
 
       // disabled
       writer.writeText(ComponentUtil.getBooleanAttribute(treeNode, ATTR_DISABLED), null);
-      
-      // resources
-      writer.writeText(",treeResourcesHelp", null);
       writer.writeText(",", null);
 
-      // action (not implemented)
-      writer.writeText("null", null);
-      writer.writeText(",", null);
+      // resources
+      writer.writeText("treeResourcesHelp,", null);
+
+      // action link
+      String actionLink =
+          (String) treeNode.getAttributes().get(ATTR_ACTION_LINK);
+      LOG.fatal("actionLink = '" + actionLink + "'");
+      if (actionLink != null) {
+        writer.writeText("'", null);
+        writer.writeText(actionLink, null);
+        writer.writeText("',", null);
+      } else {
+        writer.writeText("null,", null);
+      }
+
+      // onclick
+      String onclick = (String) treeNode.getAttributes().get(ATTR_ONCLICK);
+      if (onclick != null) {
+        writer.writeText("'", null);
+        onclick = onclick.replaceAll("\\'", "\\\\'");
+        LOG.fatal("onclick = '" + onclick + "'");
+        writer.writeText(onclick, null);
+        writer.writeText("',", null);
+      } else {
+        writer.writeText("null,", null);
+      }
 
       // parent
       if (jsParentClientId != null) {
@@ -323,5 +359,15 @@
         LOG.debug(debuging);
       }
     }
+  }
+
+  private UITree findTree(UIComponent component) {
+    while (component != null) {
+      if (component instanceof UITree) {
+        return (UITree) component;
+      }
+      component = component.getParent();
+    }
+    return null;
   }
 }

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTag.java?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTag.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTag.java Fri Nov 17 07:32:08 2006
@@ -18,9 +18,9 @@
  */
 
 import org.apache.myfaces.tobago.component.UITreeNode;
-import org.apache.myfaces.tobago.taglib.component.TobagoTag;
+import org.apache.myfaces.tobago.taglib.component.AbstractCommandTag;
 
-public class TreeNodeTag extends TobagoTag implements TreeNodeTagDeclaration {
+public class TreeNodeTag extends AbstractCommandTag implements TreeNodeTagDeclaration {
 
   @Override
   public String getComponentType() {

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTagDeclaration.java?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTagDeclaration.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/taglib/sandbox/TreeNodeTagDeclaration.java Fri Nov 17 07:32:08 2006
@@ -22,7 +22,7 @@
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
 import org.apache.myfaces.tobago.taglib.decl.HasLabel;
-import org.apache.myfaces.tobago.taglib.component.TobagoTagDeclaration;
+import org.apache.myfaces.tobago.taglib.component.AbstractCommandTagDeclaration;
 
 /**
  * Creates a tree node.
@@ -32,6 +32,6 @@
 @UIComponentTag(
     uiComponent = "org.apache.myfaces.tobago.component.UITreeNode",
     rendererType = "TreeNode")
-public interface TreeNodeTagDeclaration extends TobagoTagDeclaration,
-    HasIdBindingAndRendered, HasLabel {
+public interface TreeNodeTagDeclaration
+    extends HasIdBindingAndRendered, HasLabel, AbstractCommandTagDeclaration {
 }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java Fri Nov 17 07:32:08 2006
@@ -17,30 +17,31 @@
  * limitations under the License.
  */
 
-/*
-  * Created 21.09.2004 at 17:26:57.
-  * $Id$
-  */
-
 import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import java.io.IOException;
 
+/**
+ * Rendering is done by MenuBarRenderer,
+ * but we need decoding in CommandRendererBase.
+ * @see MenuBarRenderer
+ * @see CommandRendererBase
+ */
 public class MenuCommandRenderer extends CommandRendererBase {
 
-  // rendering is done by MenuBarRenderer,
-  // but we need decoding in CommandRendererBase
-
+  @Override
   public void encodeBegin(FacesContext facesContext, UIComponent component)
       throws IOException {
   }
 
+  @Override
   public void encodeChildren(FacesContext facesContext, UIComponent component)
       throws IOException {
   }
 
+  @Override
   public void encodeEnd(FacesContext facesContext, UIComponent component)
       throws IOException {
   }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldNodeRenderer.java?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldNodeRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeOldNodeRenderer.java Fri Nov 17 07:32:08 2006
@@ -274,6 +274,10 @@
       writer.writeText("null", null);
       writer.writeText(",", null);
 
+      // onclick (not implemented)
+      writer.writeText("null", null);
+      writer.writeText(",", null);
+
       // parent
       if (jsParentClientId != null) {
         writer.writeText(jsParentClientId, null);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tree.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tree.js?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tree.js (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tree.js Fri Nov 17 07:32:08 2006
@@ -296,7 +296,7 @@
     hideRoot, treeHiddenId, selectable, mutable,
     formId, selected, marked,
     expanded, required, disabled, treeResources,
-    action, parent, icon, openIcon, width) {
+    action, onclick, parent, icon, openIcon, width) {
   this.label = label;
 	this.id = id;
   Tobago.treeNodes[id] = this;
@@ -317,6 +317,7 @@
   this.disabled = disabled;
   this.treeResources = treeResources;
 	this.action = action;
+	this.onclick = onclick;
   this.icon = icon
       || treeResources.getImage("foldericon.gif");
   this.openIcon = openIcon
@@ -528,10 +529,9 @@
   LOG.debug("doClick on tree;");
   this.singleClick = false;
   if (this.action && !this.disabled) {
-    // str += '<a class="' + itemStyle + '" href="' + this.action + '" id="'
-    //      + this.id + '-anchor">' + this.label + '</a>';
-
-    // not yet supported see TreeNodeRenderer r464525 line 278
+    Tobago.navigateToUrl(this.action);
+  } else if (this.onclick && !this.disabled) {
+    eval(this.onclick);
   } else {
     if (this.mutable) {
       storeMarker(Tobago.element(this.id), this.treeHiddenId);

Modified: myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/button.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/button.jsp?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/button.jsp (original)
+++ myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/button.jsp Fri Nov 17 07:32:08 2006
@@ -23,13 +23,21 @@
     <f:subview id="button">
       <tc:panel>
         <f:facet name="layout">
-          <tc:gridLayout columns="100px;*" rows="fixed;*" />
+          <tc:gridLayout columns="100px;*" rows="fixed;fixed;fixed;*" />
         </f:facet>
         <%-- code-sniplet-start id="button" --%>
         <tc:button label="Submit"/>
         <%-- code-sniplet-end id="button" --%>
         <tc:cell/>
-        <tc:cell spanX="2"/>
+
+        <tc:button label="On Click" onclick="alert('Hallo Tobago!');"/>
+        <tc:cell/>
+
+        <tc:button label="Link" link="http://myfaces.apache.org/tobago/"/>
+        <tc:cell/>
+
+        <tc:cell/>
+        <tc:cell/>
       </tc:panel>
     </f:subview>
   </jsp:body>

Modified: myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/sheet.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/sheet.jsp?view=diff&rev=476178&r1=476177&r2=476178
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/sheet.jsp (original)
+++ myfaces/tobago/trunk/tobago-tool/gendoc/src/main/webapp/screenshot/sheet.jsp Fri Nov 17 07:32:08 2006
@@ -44,7 +44,8 @@
 
         <tc:messages/>
 
-        <tc:sheet value="#{simpleList}" columns="*" var="bean">
+        <tc:sheet value="#{simpleList}" columns="*;*" var="bean">
+          <tc:columnSelector />
           <tc:column label="Number">
             <tc:in value="#{bean.name}" required="true"/>
           </tc:column>