Description
I'm trying to have a wicket LinkTree collapse and expand subtrees when I click on the respective nodes. I have the following code:
tree = new LinkTree("tree", createTreeModel()) {
@Override
protected void onNodeLinkClicked(final TreeNode node, final BaseTree tree, final AjaxRequestTarget target) {
if (!node.isLeaf()) {
if (tree.getTreeState().isNodeExpanded(node))
else
{ expandAll(node); } tree.updateTree(target);
} else
}
};
with the methods expandAll/collapseAll as follows:
protected void collapseAll(final TreeNode treeNode) {
tree.getTreeState().collapseNode(treeNode);
for (final Enumeration e = treeNode.children(); e.hasMoreElements()
}
protected void expandAll(final TreeNode treeNode) {
tree.getTreeState().expandNode(treeNode);
for (final Enumeration e = treeNode.children(); e.hasMoreElements()
}
However, I keep getting the following errors (specifically, this happens when I collapse a subtree first, and then collapse a subtree of which the other subtree is a sibling):
java.lang.IllegalStateException: No Page found for component [MarkupContainer [Component id = 200, page = <No Page>, path = 200.AbstractTree$TreeItem]]
at org.apache.wicket.Component.getPage(Component.java:1639)
at org.apache.wicket.ajax.AjaxRequestTarget.respondComponent(AjaxRequestTarget.java:689)
at org.apache.wicket.ajax.AjaxRequestTarget.respondComponents(AjaxRequestTarget.java:605)
at org.apache.wicket.ajax.AjaxRequestTarget.respond(AjaxRequestTarget.java:520)
at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:103)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1172)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1241)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1316)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:354)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)