I’m using Richfaces 3, Facelets (a pre-JSF 2 version), and Tomcat. I am working on adding a Richfaces Tree to my page, but get this error:
org.richfaces.model.TreeNodeImpl cannot be cast to javax.swing.tree.TreeNode
Here is the code I’m using to build the list of nodes:
int i = 0;
TreeNodeImpl<String> rootNode = new TreeNodeImpl<String>();
for( Recommendation recommendation : m_recommendationsBean.getRecommendations() )
{
final TreeNodeImpl<String> childNode = new TreeNodeImpl<String>();
childNode.setData( recommendation.getEventDescription() );
rootNode.addChild( i, childNode );
i++;
}
m_treeNodes.add( rootNode );
And then:
@NotNull
public List<TreeNodeImpl<String>> getTreeNodes ()
{
return m_treeNodes;
}
And my page just has this:
<rich:tree value="#{DmsRecommendationsPage.treeNodes}" var="recommendation">
<rich:treeNode>
#{recommendation}
</rich:treeNode>
</rich:tree>
Any ideas? Thanks!
Check your imports. RichFaces’ own
org.richfaces.model.TreeNodeinterface should be used in the property declaration. You’ve likely picked the first option of the IDE autosuggestion to import the Swing one instead of the RichFaces one while declaring theTreeNode.Replace
by