Hi all, I'm using a Tree for navigation and I have a need to load an external page in a new window when a link is clicked in the tree. I was hoping to put something in the onNodeLinkClicked function for my tree that could create/call a JS function to load the URL in a new window as required. This does not need to be done for the entire tree structure, so I need to be able to set up this functionality for specified nodes only. Is there a way to do this?
I have read the JS related article on the wiki (http://cwiki.apache.org/WICKET/calling-javascript-function-on-wicket-components-onclick.html), but I don't see how to add this to only a few nodes in a tree. Here's my tree definition: private Tree getTree() { final Tree linkTree = new Tree("navTree", createNavigationTreeModel()) { private static final long serialVersionUID = -4646756742893751770L; @Override protected void onNodeLinkClicked(AjaxRequestTarget target, TreeNode node) { // If this is a MenuItem, reload content. if (((DefaultMutableTreeNode) node).getUserObject() instanceof MenuItem) { MenuItem menuItem = (MenuItem) ((DefaultMutableTreeNode) node).getUserObject(); Panel contentPanel = menuItem.getContent(); contentPanel.setOutputMarkupId(true); MenuPanel.this.getParent().replace(contentPanel); target.addComponent(contentPanel); } else if (((DefaultMutableTreeNode) node).getUserObject() instanceof Menu) { Menu menu = (Menu) ((DefaultMutableTreeNode) node).getUserObject(); // Use Javascript to open new window? Get URL from menu object. } getTreeState().selectNode(node, true); super.onNodeLinkClicked(target, node); } }; linkTree.setRootLess(true); linkTree.setOutputMarkupId(true); return linkTree; } The if(MenuItem) replace portion works great, it's the else if(Menu) part that has me stuck. Thanks in advance for any suggestions or comments. -- Amanda
