Are the ActionLinks being processed?
No they're not :(. The onProcess method does not appear in the logs,
nor is the action method called.
The PageLink of course does not need this since there's nothing to
process there.
Are the ActionLinks controls
registered with a parent container or page?
Yes I added("registered" with addControl() ), the ActionLink controls to
the page :(.
I created in Click Examples a page - ActionLinkTreePage that is
reproduction the problem you mention (see attachment - the example is
based on the PageLinkTreePage).
A.
Index: examples/webapp/tree/action-link-tree-page.htm
===================================================================
--- examples/webapp/tree/action-link-tree-page.htm (revision 0)
+++ examples/webapp/tree/action-link-tree-page.htm (revision 0)
@@ -0,0 +1,10 @@
+Provides a demonstration of using the Tree component to link to different
actions with
+different parameters.
+
+<p/>
+$tree
+<p/>
+
+#if($actionMsg)
+ $actionMsg
+#end
\ No newline at end of file
Property changes on: examples\webapp\tree\action-link-tree-page.htm
___________________________________________________________________
Added: svn:eol-style
+ native
Index: examples/src/org/apache/click/examples/page/tree/ActionLinkTreePage.java
===================================================================
--- examples/src/org/apache/click/examples/page/tree/ActionLinkTreePage.java
(revision 0)
+++ examples/src/org/apache/click/examples/page/tree/ActionLinkTreePage.java
(revision 0)
@@ -0,0 +1,70 @@
+package org.apache.click.examples.page.tree;
+
+import org.apache.click.control.ActionLink;
+import org.apache.click.extras.tree.TreeNode;
+import org.apache.click.extras.tree.Tree;
+import org.apache.click.util.HtmlStringBuffer;
+import org.apache.commons.lang.StringUtils;
+
+public class ActionLinkTreePage extends PlainTreePage {
+ public String myParam;
+ /**
+ * Creates and return a new tree instance. A Page object could be also sent
+ * as final parameter to be used by addControl(link) - the result will be
the same.
+ */
+ protected Tree createTree() {
+ return new Tree("tree") {
+
+ private static final long serialVersionUID = 1L;
+
+ protected void renderValue(HtmlStringBuffer buffer, TreeNode
treeNode) {
+ String nodeValue = (String) treeNode.getValue();
+ String nodeId = treeNode.getId();
+
+ // If node value is a Page class, render a PageLink, otherwise
+ // render the node value
+ if (nodeId.startsWith("add_")) {
+ ActionLink link = new
ActionLink(nodeId,nodeValue,this,"onAddClick");
+ link.setParameter("myParam",
StringUtils.substringAfter(nodeId,"add_"));
+ addControl(link);
+ buffer.append(link);
+ } else if(nodeId.startsWith("remove_")) {
+ ActionLink link = new
ActionLink(nodeId,nodeValue,this,"onRemoveClick");
+ link.setParameter("myParam",
StringUtils.substringAfter(nodeId,"remove_"));
+ addControl(link);
+ buffer.append(link);
+ } else {
+ buffer.append(nodeValue);
+ }
+ }
+ };
+ }
+
+ protected TreeNode createNodes() {
+ TreeNode root = new TreeNode("Actions");
+ TreeNode addNode = new TreeNode("Add actions","add",root);
+ new TreeNode("Add object 1","add_1",addNode,false);
+ new TreeNode("Add object 2","add_2",addNode,false);
+ new TreeNode("Add object 3","add_3",addNode,false);
+ TreeNode removeNode = new TreeNode("Remove actions","remove",root);
+ new TreeNode("Remove object 1","remove_1",removeNode,false);
+ new TreeNode("Remove object 2","remove_2",removeNode,false);
+ new TreeNode("Remove object 3","remove_3",removeNode,false);
+ return root;
+ }
+
+ public boolean onAddClick(){
+ // do something here
+ System.out.println("-----> onAddClick() should be called!");
+ addModel("actionMsg","Add object "+myParam);
+ return true;
+ }
+
+ public boolean onRemoveClick(){
+ // do something here
+ System.out.println("-----> onRemoveClick() should be called!");
+ addModel("actionMsg","Remove object "+myParam);
+ return true;
+ }
+
+}
Property changes on:
examples\src\org\apache\click\examples\page\tree\ActionLinkTreePage.java
___________________________________________________________________
Added: svn:eol-style
+ native
Index: examples/webapp/WEB-INF/menu.xml
===================================================================
--- examples/webapp/WEB-INF/menu.xml (revision 768331)
+++ examples/webapp/WEB-INF/menu.xml (working copy)
@@ -123,6 +123,7 @@
<menu label="Advanced Tree" path="tree/advanced-tree-page.htm"/>
<menu label="Checkbox Tree" path="tree/checkbox-tree-page.htm"/>
<menu label="Page Link Tree" path="tree/page-link-tree-page.htm"/>
+ <menu label="Action Link Tree" path="tree/action-link-tree-page.htm"/>
</menu>
<menu label=" Panel" path="#" imageSrc="/assets/images/panel.png">