PDA

View Full Version : [2.0.1] BaseTreeModel children, setChildren(), getChildren()



francescoNemesi
4 Aug 2009, 12:18 AM
Hello,

in my opinion the "children" instance variable (and its getter and setter methods) of com.extjs.gxt.ui.client.data.BaseTreeModel should be changed from

protected List<ModelData> children;

to

protected List<M extends ModelData> children;

The current implementation actually makes the setChildren() and getChildren() methods very unflexible for classes that extends BaseTreeModel. For these classes, in fact, one would expect their children as being as

List<MyClassesThatExtendsBaseTreeModel>

and not simply

List<ModelData>

as it is defined now. The only way round at the moment is to loop through the children using the get() and set() methods and cast explicitely from ModelData to MyClassesThatExtendsBaseTreeModel, this can be cause performance problems for large models as well as being an unnecessary coding burden for the developer.

I came across this issue while migrating to 2.0.1 from 1.2.4 where this problem was not there as BaseTreeModel was "java generically" defined. I also posted in the Help Forum here:

http://extjs.com/forum/showthread.php?t=75018

I hope I made myself clear on this.

Regards, Thanks

Francesco

sven
4 Aug 2009, 1:20 AM
The only way round at the moment is to loop through the children using the get() and set() methods and cast explicitely from ModelData to MyClassesThatExtendsBaseTreeModel, this can be cause performance problems for large models as well as being an unnecessary coding burden for the developer.

Why you need to loop over it?

As this is more a feature request than a actual software bug i am moving this to the help forum.

francescoNemesi
4 Aug 2009, 3:34 AM
Hi,

One needs to loop the children list as at the moment it is not possible to


List<MyClassThatExtendsBaseTreeModel> someChildren;
MyClassThatExtendsBaseTreeModel myClassInstance = new MyClassThatExtendsBaseTreeModel()

myClassInstance.setChildren(someChildren);

Because setChildren only accepts List<ModelData>. Same reasoning goes for getChildren().

You are right it is not a bug as such, but it is a limiting feature which was not there before and I do not see a reason for it to be there now.

Thanks,
Francesco

Arno.Nyhm
6 Aug 2009, 6:21 AM
is there a good explanation why you change it from <T extends TreeModel> not to <T extends ModelData>?

francescoNemesi
6 Aug 2009, 6:35 AM
No, my mistake, I meant

<T extends ModelData>

as stated in my first post

Arno.Nyhm
10 Aug 2009, 3:22 AM
and my question was going to @sven why this step back was between the versions....

A100037
12 Aug 2009, 3:07 AM
We experience the same major migration problem here. Parent generic have been removed from data model. 95% of migration effort is linked to this change.

This Breaking API Change is a major change with huge impact for all customer that used generic in 1.2.4.