I'm having kind of a similar problem with tree selection. I've created a small project with jboss as 7.1.4, mojarra 2.2.1 and RF 4.3.5.
Node:
public class TreeNode extends TreeNodeImpl {
public String data;
public String type = "NODE";
public TreeNode() {
}
public TreeNode(String data) {
this.data = data;
}
public TreeNode(boolean leaf, String data) {
super(leaf);
if (leaf) {
type = "LEAF";
}
this.data = data;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
Backing bean:
@ManagedBean
@SessionScoped
public class TreeBean implements Serializable {
public TreeNode getTree() {
TreeNode root = new TreeNode();
TreeNode child = new TreeNode("child 1");
TreeNode subChild = new TreeNode(true, "subchild 1");
child.addChild(0, subChild);
subChild = new TreeNode(true, "subchild 2");
child.addChild(1, subChild);
root.addChild(0, child);
child = new TreeNode("child 2");
subChild = new TreeNode(true, "subchild 3");
child.addChild(0, subChild);
subChild = new TreeNode(true, "subchild 4");
child.addChild(1, subChild);
root.addChild(1, child);
child = new TreeNode("child 3");
root.addChild(2, child);
return root;
}
public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent) {
System.out.println("selectionChangeEvent = " + selectionChangeEvent);
}
}
xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<title>RF Hello World</title>
</h:head>
<h:body>
<h3>RF Hello World</h3>
<h:form>
<rich:tree id="tree" value="#{treeBean.tree}" var="node" toggleType="client"
selectionType="ajax" selectionChangeListener="#{treeBean.selectionChanged}" nodeType="#{node.type}">
<rich:treeNode type="NODE">
<h:outputText value="NODE: #{node.data}" />
</rich:treeNode>
<rich:treeNode type="LEAF">
<h:outputText value="LEAF: #{node.data}" />
</rich:treeNode>
</rich:tree>
<br/>
<a4j:commandLink value="refresh" render="tree, randomNumber" limitRender="true" />
<br></br>
<h:outputText value="#{helloBean.randomNumber()}" id="randomNumber" />
</h:form>
</h:body>
</html>
If I select any node, nothing happens and I get this error:
13:43:45,848 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-/0.0.0.0:8080-4) JSF1007: Duplicate component ID j_idt6:tree:j_idt10 found in view.
13:43:45,848 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-/0.0.0.0:8080-4) +id: j_id1
type: javax.faces.component.UIViewRoot@26c94ab9
+id: javax_faces_location_HEAD
type: com.sun.faces.component.ComponentResourceContainer@5d90f7e6
+id: __rf_skinning_resource
type: javax.faces.component.UIOutput@58834d07
+id: j_id2
type: javax.faces.component.UIOutput@143633f7
+id: j_id3
type: javax.faces.component.UIOutput@728da77e
+id: j_id4
type: javax.faces.component.UIOutput@31ef7bf3
+id: j_id5
type: javax.faces.component.UIOutput@61b2a821
+id: j_id6
type: javax.faces.component.UIOutput@183c40a3
+id: j_id7
type: javax.faces.component.UIOutput@1bb799c3
+id: j_id8
type: javax.faces.component.UIOutput@32cfdf6c
+id: j_id9
type: javax.faces.component.UIOutput@6d554583
+id: j_idt1
type: <html xmlns="http://www.w3.org/1999/xhtml">
+id: j_idt2
type: javax.faces.component.UIOutput@6948cb93
+id: j_idt3
type:
<title>RF Hello World</title>
+id: j_idt4
type: javax.faces.component.UIOutput@6624305
+id: j_idt5
type:
<h3>RF Hello World</h3>
+id: j_idt6
type: javax.faces.component.html.HtmlForm@1d1e0089
+id: j_idt7
type: javax.faces.component.html.HtmlInputText@1cb5314e
+id: j_idt8
type: javax.faces.component.html.HtmlCommandButton@3bb8069b
+id: j_idt9
type:
<br/><br/>
+id: tree
type: org.richfaces.component.UITree@2eb9c8be
+id: __defaultTreeNode
type: org.richfaces.component.UITreeNode@7946d388
+id: j_id3
type: javax.faces.component.html.HtmlOutputText@18e9c3ec
+id: j_idt10
type: org.richfaces.component.UITreeNode@1b3dc7bb
+id: j_idt11
type: javax.faces.component.html.HtmlOutputText@7503d3f5
+id: j_idt12
type: org.richfaces.component.UITreeNode@4e50b5d7
+id: j_idt13
type: javax.faces.component.html.HtmlOutputText@14d25e6c
+id: j_idt10
type: org.richfaces.component.UITreeNode@272a49e9
+id: j_idt11
type: javax.faces.component.html.HtmlOutputText@495a7415
+id: j_idt12
type: org.richfaces.component.UITreeNode@517b3452
+id: j_idt13
type: javax.faces.component.html.HtmlOutputText@6fa81d48
+id: j_idt14
type:
<br/>
+id: j_idt15
type: org.richfaces.component.UICommandLink@61a9b3d
+id: j_idt16
type:
<br/>
+id: randomNumber
type: javax.faces.component.html.HtmlOutputText@3cc5c4ec
+id: j_idt17
type:
</html>
13:43:45,848 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-/0.0.0.0:8080-4) Error Rendering View[/index.xhtml]: java.lang.IllegalStateException: Component ID j_idt6:tree:j_idt10 has already been found in the view.
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:832) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:816) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:816) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:816) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.application.view.FaceletFullStateManagementStrategy.saveView(FaceletFullStateManagementStrategy.java:686) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:89) [jsf-impl-2.1.16-jbossorg-1.jar:]
at javax.faces.application.StateManager.getViewState(StateManager.java:553) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at org.richfaces.context.ExtendedPartialViewContextImpl.renderState(ExtendedPartialViewContextImpl.java:416) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]
at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialRenderPhase(ExtendedPartialViewContextImpl.java:313) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]
at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:213) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:979) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:411) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124) [jsf-impl-2.1.16-jbossorg-1.jar:]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.16-jbossorg-1.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.17.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.1.4.Final-SNAPSHOT.jar:7.1.4.Final-SNAPSHOT]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.17.Final.jar:]
at org.jboss.web.rewrite.RewriteValve.invoke(RewriteValve.java:466) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372) [jbossweb-7.0.17.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.17.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679) [jbossweb-7.0.17.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.17.Final.jar:]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
13:43:45,850 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/jsf_test_war_exploded].[Faces Servlet]] (http-/0.0.0.0:8080-4) Servlet.service() for servlet Faces Servlet threw exception: java.lang.IllegalStateException: CDATA tags may not nest
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startCDATA(HtmlResponseWriter.java:664) [jsf-impl-2.1.16-jbossorg-1.jar:]
at javax.faces.context.ResponseWriterWrapper.startCDATA(ResponseWriterWrapper.java:172) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at javax.faces.context.PartialResponseWriter.startError(PartialResponseWriter.java:342) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at org.richfaces.context.PartialResponseWriterWrapper.startError(PartialResponseWriterWrapper.java:116) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]
at org.richfaces.context.DeferredEndingPartialResponseWriter.startError(DeferredEndingPartialResponseWriter.java:75) [richfaces-core-impl-4.3.5.Final.jar:4.3.5.Final]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:200) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:124) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.16-jbossorg-1.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.16-jbossorg-1.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.9.Final.jar:2.0.9.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.17.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.1.4.Final-SNAPSHOT.jar:7.1.4.Final-SNAPSHOT]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.17.Final.jar:]
at org.jboss.web.rewrite.RewriteValve.invoke(RewriteValve.java:466) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372) [jbossweb-7.0.17.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.17.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679) [jbossweb-7.0.17.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.17.Final.jar:]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
If I click on refresh link, which is under the tree just for testing purposes, the first time everything works fine, the second time the same error is thrown.
I really don't understand what's wrong. It look like there is also some kind of problem with nodeType attribute, because when I remove noteType from rich:tree it doesn't throw any exceptions but neither the selectionChanged method is invoked.