Hello All,
I have one tree with structure like…
–root
----------child level1
-----------------child level2
-------------------------Element 1
-------------------------Element 2
-------------------------Element 3
-------------------------Element 4
And I have row selected check box for selecting row.
Now with click on one command button I want to retrieve selected row details.But not able to get achieve this.
I have code like this…
List a=dataTestProvider.getSelectedRows();
for(int i=0;i<a.size();i++)
{
Test g=(Test) a.get(i);//Test is the Object for row class
System.out.println(“name:”+g.getName());
}
But always I am getting error as Can’t be converted to this class.
Is there any alternative way to read the rows of selected rows in tree…because same code is working in table structure.
And also working for List a=dataTestProvider.getList(); instead of getSelectedRows();
Ok. The BoundChildrenTreeContentProvider wraps your row objects with another object to adapt them to a format suitable for the tree.
You can retrieve the original object from the wrapper with something like this:
//the row is the wrapper object
BoundChildrenNode$PermissiveContentProviderWrapper wrapper = (BoundChildrenNode$PermissiveContentProviderWrapper)a.get(i);
//get the original object that was wrapped.
Test g=(Test) wrapper.getObject();//Test is the Object for row class
PermissiveContentProviderWrapper wrapper=(PermissiveContentProviderWrapper) a.get(i);
Test g=(Test) wrapper.getObject();
Here I am able to get selected row details.
Now facing problem here is to add the selected row again to Tree/TreeProvider with some editted contents.
when trying to use methods treeProvider.createRow() …getting one error like
com.data.Customer cannot be cast to com.webMethods.caf.faces.data.tree.INode.