Hello,
I use GWT 2.2 and SGWT 2.4.
I have a custom TreeGrid (PatientTree), a custom DataSource (ClinicalDS) and a custom TreeNode (CliniCalNode).
I want to load on datasource children of a node when I open parent node/folder. Everything is ok on the first level of nodes. I open the parent, children are loaded !
But when I want to open newly created children, a cast exception occurs:
Here are my classes :
some screenshots :
- 1.png => first level loaded by ds.initialize() => OK
- 2.png => second level loaded by ds.addchild() => OK
- 3.png => I log the toString() of the node => first line : click on Patient1 OK, second line click on Prel1 KO
thanks ;)
Pierre
I use GWT 2.2 and SGWT 2.4.
I have a custom TreeGrid (PatientTree), a custom DataSource (ClinicalDS) and a custom TreeNode (CliniCalNode).
I want to load on datasource children of a node when I open parent node/folder. Everything is ok on the first level of nodes. I open the parent, children are loaded !
But when I want to open newly created children, a cast exception occurs:
Code:
java.lang.ClassCastException: com.smartgwt.client.widgets.tree.[B]TreeNode cannot be cast to[/B] org.ub.le2i.[B]ClinicalNode [/B]
Code:
class [B]PatientTree [/B] extends TreeGrid{ ClinicalDS ds; public [B]PatientTree[/B](){ ds = new ClinicalDS(); ds.initialize(); this.setDataSource(ds); [B]addFolderOpenedHandler[/B](new FolderOpenedHandler() { public void onFolderOpened(FolderOpenedEvent event) { ClinicalNode node = (ClinicalNode) event.getNode(); // CAST EXCEPTION ds.[B]addChildren[/B](node); } }); } }
Code:
class [B]ClinicalDS[/B] extends DataSource{ public void [B]initialize[/B](){ // load patients from database : List<Patient> patients; for (Patient patient : patients){ [B]ClinicalNode [/B]child = new [B]ClinicalNode[/B](patient); addData(child); } } public void [B]addChildren[/B](ClinicalNode parent){ // load samples from database : List<Sample> samples; for (Sample sample: samples){ [B]ClinicalNode [/B]child = new [B]ClinicalNode[/B](sample); child.setParent(parent); addData(child); } } }
Code:
class [B]ClinicalNode[/B] extends TreeNode{ private Object object; public ClinicalNode([B]Patient [/B]patient){ // setAttributes, etc. object = patient; // this is why I need a custom TreeNode } public ClinicalNode([B]Sample [/B]sample){ // setAttributes, etc. object = sample; } }
- 1.png => first level loaded by ds.initialize() => OK
- 2.png => second level loaded by ds.addchild() => OK
- 3.png => I log the toString() of the node => first line : click on Patient1 OK, second line click on Prel1 KO
thanks ;)
Pierre
Comment