View Full Version : HELP ME PLEASE: BaseTreeModel Doesn't Load Children After Adding Property

9 May 2010, 9:20 PM
Please help me!! I'm already desperate searching for the solution of this problem.

I have Asynchronous TreePanel that loads SubjectTreeEntry (extending BaseTreeModel) from the server. It was sucessfully load the first node model.

My application needs to modify the model in client side (such as setting the icon). So I created the code below which sets several properties (especially "icon") after successful load:

TreeLoader<SubjectTreeEntry> loader = new BaseTreeLoader<SubjectTreeEntry>(proxy) {
protected void onLoadSuccess(Object loadConfig, List<SubjectTreeEntry> result) {
// Set content and icon for each entry
for (Iterator<SubjectTreeEntry> iterator = result.iterator(); iterator.hasNext();) {
SubjectTreeEntry entry = (SubjectTreeEntry) iterator.next();
switch (entry.getType()) {
case SubjectTreeEntryType.SUBJECT_ROOT:
entry.setContent(new SubjectListView(window));
case SubjectTreeEntryType.SUBJECT:
super.onLoadSuccess(loadConfig, result);

public boolean hasChildren(SubjectTreeEntry parent) {
return parent.hasChildren();
};The icon is rendered, but the problem is the root node can not load the children after I modify the model with that code. The icon changed to loading icon but there is no request to the server.

I have also tried to move that code inside ModelProcessor, but it still not work.

It works fine and successfully load the children if I remove that code above.

My question is: How can we safely add the models' properties after they are received from the server, but before they're rendered/processed by the treepanel??

Thank you very much.

10 May 2010, 6:37 PM

Finally I know the problem.

entry.setContent(new SubjectListView(window));
entry.setIcon(Resources.ICONS.subject16())It is because I set unserializable objects into the model. Yes, SubjectListView is a subclass of ContentPanel and the icon is AbstractImagePrototype. They are unserializable objects. That's why the root node cannot make a request to load the children (it stops after loading icon appears).

Now, my application creates a copy of loadConfig before call the service:

SubjectTreeEntry lc = (SubjectTreeEntry) loadConfig;
SubjectTreeEntry newLoadConfig = new SubjectTreeEntry(lc.getId(), lc.getName(), lc.getType());
The newLoadConfig doesn't has content and icon.