0

java.util.ConcurrentModificationException while UI-Update (Listbox)

asked 2008-07-14 16:16:04 +0800

robertpic71 gravatar image robertpic71
1275 1

I wrote a databinding (list) models, which handels jdbc conversation/paging for the annotation databinder.
I want to handle big tables to. So i wrote a "growing model":
I load 5 pages at first. When the user showed i.e. the 4. page, i let grow the model with the next 5 pages.

My Problem:
I have to inform to UI about the new Size. When i fire an UI-Update, i get this messages:

addChd
D has not properties

14.07.2008 16:35:06 org.zkoss.zk.ui.impl.UiEngineImpl handleError:874
SCHWERWIEGEND: >>java.util.ConcurrentModificationException
>> at org.zkoss.zk.ui.AbstractComponent$ChildIter.checkComodification(AbstractComponent.java:1765)
>> at org.zkoss.zk.ui.AbstractComponent$ChildIter.next(AbstractComponent.java:1743)
>> at org.zkoss.zul.Listbox$ItemIter.next(Listbox.java:1863)
>> at org.zkoss.zul.Listbox$5.onEvent(Listbox.java:920)
>> at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:197)
>>...

My source:

... extends BindingListModelList..
..
public Object getElementAt(int j) {
       // watermark triggered? -> loadNext pages
	if (j > trigger) {
	    loadNext(this.getSize(), limit);
	}
	
	return _list.get(j);
    }
...
loadNext {
...
while(rs.next()) {
	    fieldMap = new HashMap<String, Object>(columnCount, 1);
	    for (int i = 0; i < columnCount; i++) {
		fieldMap.put(fieldNames<i >, rs.getObject(i+1));
	    }
	    log.info("gesetzt " + index);
	    this.add(fieldMap); // add new Objekt to List (add including a fireEvent)
	    // _list.add(fieldMap);
           // fireEvent(ListDataEvent.INTERVAL_ADDED, index-1, index-1);
	    index++;
	}
}

I've tried more options:
1.) use the original add(object) from BindingListModelList
2.) fire an own event for each record
3.) fire one event for all new records - like addAll()

I always get the same error.

Any suggestions?
Is there another way to extend the UI-List?

/Robert

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2008-07-16 06:23:31 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

1. The onPaging event trigger the event handler org.zkoss.zul.Listbox$5.onEvent(Listbox.java:920)
2. The onPaging event handler iterate the Listitems (getItems()) of the Listbox to "render" the Listcells which will call getElementAt() method of ListModel.
3. Your getElementAt() method will test the water mark and "grow the table" which then fireevent to add more Listitem (though not rendered yet).
4. Since in (2) onPaging event handler is iterate getItems() and you change the Listitem list in (3), a java.util.ConcurrentModificationException is thrown.

Three way to solve this:

1. grow the table just before the "internal" onPaging (write own onPaging event handler to grow the table)
2. grow the table after the "internal" onPaging (post an user event, say onGrowTable, to have your event handler to grow the table)
3. use own Paging component with a total control on the paging mechanism.

link publish delete flag offensive edit

answered 2008-07-17 03:58:46 +0800

robertpic71 gravatar image robertpic71
1275 1

Thanks henri - it work's

see BindJDBC8b.zul

/Robert

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-07-14 16:16:04 +0800

Seen: 1,075 times

Last updated: Jul 17 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More