-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi there,
after realizing a list iterator obtained by invoking listIterator() on a ListModelList instance failed to update the underlying listbox upon item removal I gazed into the source code just to find that listIterator() != listIterator( 0 ):
public ListIterator listIterator() { return _list.listIterator(); } public ListIterator listIterator(final int index) { return new ListIterator() { private ListIterator _it = _list.listIterator(index); private Object _current = null; public boolean hasNext() { return _it.hasNext(); } public Object next() { _current = _it.next(); return _current; } public void remove() { final int index = _list.indexOf(_current); if (index >= 0) { removeSelection(_current); _it.remove(); fireEvent(ListDataEvent.INTERVAL_REMOVED, index, index); } } public void add(Object arg0) { final int index = _it.nextIndex(); _it.add(arg0); fireEvent(ListDataEvent.INTERVAL_ADDED, index, index); } public boolean hasPrevious() { return _it.hasPrevious(); } public int nextIndex() { return _it.nextIndex(); } public Object previous() { _current = _it.previous(); return _current; } public int previousIndex() { return _it.previousIndex(); } public void set(Object arg0) { final int index = _list.indexOf(_current); if (index >= 0) { _it.set(arg0); fireEvent(ListDataEvent.CONTENTS_CHANGED, index, index); } } }; }
Such a behaviour is rather counterintuitive for me, specially because the javadoc does not say anything about this difference (wheter really meant for or just introduced by mistake).
With kind regards
César Varona
Hi cvarona,
What of ZK version do you using?
Hi cvarona,
Thanks for you suggestion, I have checkin the modify.
public ListIterator listIterator() { return listIterator(0); }
Asked: 2011-05-16 10:30:10 +0800
Seen: 273 times
Last updated: May 30 '11