-
17 Jun 2008 9:43 AM #1
[CLOSED] ComboBox.select before rendering gives NullPointerException
[CLOSED] ComboBox.select before rendering gives NullPointerException
If I try to use method select just after creation ComboBox throws a NullPointerException. For example the next code:
givesCode:ComboBox comboBox = new ComboBox(); comboBox.setStore(listStore); comboBox.setDisplayField("name"); comboBox.setEditable(true); comboBox.select(1);
PS. I have 3 items in the comboBox and it works well without using method select. But I need to select values.Code:[ERROR] Uncaught exception escaped java.lang.NullPointerException: null at com.extjs.gxt.ui.client.widget.form.ComboBox.select(ComboBox.java:351)
-
17 Jun 2008 10:33 AM #2
You most likely want to be using setValue. select should only be used when the list is expanded. I changed the code so that the null pointer will not be thrown.Code:/** * Select an item in the dropdown list by its numeric index in the list. This * function does NOT cause the select event to fire. The list must expanded * for this function to work, otherwise use #setValue. * * @param index the index of the item to select */ public void select(int index) {}


Reply With Quote