I have a trying to put value from arrayList to List box. but it gives me error out of bound exception.
getListValue() returns arrayList.
for(int i = 0;i<getListValue().size();i++){
System.out.println("qsdq " +getListValue().toString()+" "+ getListValue().size());
listBox.addItem(getListValue().get(i)); // ErrorPoint
}
output
qsdq [xyz, abc] 2
Stacktrace
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IndexOutOfBoundsException: null
at com.google.gwt.user.client.ui.ListBox.checkIndex(ListBox.java:595)
at com.google.gwt.user.client.ui.ListBox.setValue(ListBox.java:511)
at com.client.GUI.MultivaluedPopup.getListBox(MultivaluedPopup.java:92) // error point
You should probably add the items first. The
setValuesonly sets the value (as the name suggests) but no new item is added.Use
listBox.Items.addbefore setting the value, or add the new item with right value in the first place by add.