Problems with NodeSelectedEvent
ashsneider Jul 21, 2008 2:51 PMHi everyone.
I am using a Rich Tree component and have a problem handling the rich tree NodeSelectedEvent.
I need to get the selected node id or name. But I get an exception handling the event:
java.lang.ClassCastException: org.richfaces.component.html.HtmlTree cannot be cast to org.richfaces.component.html.HtmlTree
Here is my listener:
-------------------------------------------------------
@Name("treelistener")
@Scope(ScopeType.EVENT)
public class TreeListener implements NodeSelectedListener{
public void processSelection(NodeSelectedEvent event)
throws AbortProcessingException {
HtmlTree tree = (HtmlTree)event.getComponent();
}
}
---------------------------------------------------------
Here is my Tree class:
------------------------------------------------------
@Name("treebean")
@Scope(ScopeType.SESSION)
public class TreeBean {
private List<Category> categoryList;
private TreeNode categoryTree = new TreeNodeImpl();
private String nodeTitle;
@Logger Log log;
/*...*/
@Create
public void createTree() {
categoryList = new CategoryList().getResultList();
try {
sort(categoryList);
addChildren();
} catch(Exception e) {
log.error("Error creating the category tree.", e.getMessage());
}
}
public String getNodeTitle() {
return nodeTitle;
}
public TreeNode getCategoryTree() {
return categoryTree;
}
public void setCategoryTree(TreeNode categoryTree) {
this.categoryTree = categoryTree;
}
------------------------------------------------------
Here is my page:
------------------------------------------------------
<h:form>
<rich:tree value="#{treebean.categoryTree}"
var="node" icon="" iconLeaf="" nodeSelectListener="#{treelistener.processSelection}"
ajaxSubmitSelection="true" >
<rich:treeNode>
<h:outputText value="#{node}"/>
</rich:treeNode>
</rich:tree>
</h:form>
------------------------------------------------------
I suppose it is some sort of a classpath problem. I have added the libraries to my ear content and to the manifest.
I desperately need an answer.
Thank you in advance.
I am using a Rich Tree component and have a problem handling the rich tree NodeSelectedEvent.
I need to get the selected node id or name. But I get an exception handling the event:
java.lang.ClassCastException: org.richfaces.component.html.HtmlTree cannot be cast to org.richfaces.component.html.HtmlTree
Here is my listener:
-------------------------------------------------------
@Name("treelistener")
@Scope(ScopeType.EVENT)
public class TreeListener implements NodeSelectedListener{
public void processSelection(NodeSelectedEvent event)
throws AbortProcessingException {
HtmlTree tree = (HtmlTree)event.getComponent();
}
}
---------------------------------------------------------
Here is my Tree class:
------------------------------------------------------
@Name("treebean")
@Scope(ScopeType.SESSION)
public class TreeBean {
private List<Category> categoryList;
private TreeNode categoryTree = new TreeNodeImpl();
private String nodeTitle;
@Logger Log log;
/*...*/
@Create
public void createTree() {
categoryList = new CategoryList().getResultList();
try {
sort(categoryList);
addChildren();
} catch(Exception e) {
log.error("Error creating the category tree.", e.getMessage());
}
}
public String getNodeTitle() {
return nodeTitle;
}
public TreeNode getCategoryTree() {
return categoryTree;
}
public void setCategoryTree(TreeNode categoryTree) {
this.categoryTree = categoryTree;
}
------------------------------------------------------
Here is my page:
------------------------------------------------------
<h:form>
<rich:tree value="#{treebean.categoryTree}"
var="node" icon="" iconLeaf="" nodeSelectListener="#{treelistener.processSelection}"
ajaxSubmitSelection="true" >
<rich:treeNode>
<h:outputText value="#{node}"/>
</rich:treeNode>
</rich:tree>
</h:form>
------------------------------------------------------
I suppose it is some sort of a classpath problem. I have added the libraries to my ear content and to the manifest.
I desperately need an answer.
Thank you in advance.