java.lang.ArrayIndexOutOfBoundsException: 2

ZK-Tracker | RichardL | 5 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    See these forum threads for more: http://www.zkoss.org/forum/listComment/18519-Setter-for-data-in-SimpleListModel and http://www.zkoss.org/forum/listComment/18504-Autocomplete-Combobox-with-huge-data-in-MVVM I've got an auto complete combobox with a custom model that extends SimpleListModel. To get my sublist for the auto complete I override getSubModel(Object obj, int nRows). I am setting the model with an empty list to start and then fetching from the database for each submodel (the data is huge, so this way is more efficient). I also have a renderer which sets both a label and a value to each combitem. I have an onChange event listener in the combobox where I want to get the value of the comboitem (not the label - I know I could just get that by getting the value of the combobox): this.addEventListener("onChange", new EventListener() { public void onEvent(Event e) throws Exception { Executions.sendRedirect("index.zul?bun=" + FindUsersAutoCompleteCombo.this.getSelectedItem().getValue()); } }); The trouble is, the getSubModel method doesn't update the data in SimpleListModel, so when I try to get the value of the comboitem I get this error (remember, I started out with an empty list in the model, and it hasn't been updated): SEVERE: java.lang.ArrayIndexOutOfBoundsException: 2 at org.zkoss.zul.SimpleListModel.getElementAt(SimpleListModel.java:92) at org.zkoss.zul.Combobox.syncSelectionToModel(Combobox.java:609) This could be solved simply with a setter for data in SimpleListModel, so the data can be updated in the getSubModel method. Thanks!

    ZK-Tracker | 5 years ago | RichardL
    java.lang.ArrayIndexOutOfBoundsException: 2
  2. 0

    See these forum threads for more: http://www.zkoss.org/forum/listComment/18519-Setter-for-data-in-SimpleListModel and http://www.zkoss.org/forum/listComment/18504-Autocomplete-Combobox-with-huge-data-in-MVVM I've got an auto complete combobox with a custom model that extends SimpleListModel. To get my sublist for the auto complete I override getSubModel(Object obj, int nRows). I am setting the model with an empty list to start and then fetching from the database for each submodel (the data is huge, so this way is more efficient). I also have a renderer which sets both a label and a value to each combitem. I have an onChange event listener in the combobox where I want to get the value of the comboitem (not the label - I know I could just get that by getting the value of the combobox): this.addEventListener("onChange", new EventListener() { public void onEvent(Event e) throws Exception { Executions.sendRedirect("index.zul?bun=" + FindUsersAutoCompleteCombo.this.getSelectedItem().getValue()); } }); The trouble is, the getSubModel method doesn't update the data in SimpleListModel, so when I try to get the value of the comboitem I get this error (remember, I started out with an empty list in the model, and it hasn't been updated): SEVERE: java.lang.ArrayIndexOutOfBoundsException: 2 at org.zkoss.zul.SimpleListModel.getElementAt(SimpleListModel.java:92) at org.zkoss.zul.Combobox.syncSelectionToModel(Combobox.java:609) This could be solved simply with a setter for data in SimpleListModel, so the data can be updated in the getSubModel method. Thanks!

    ZK-Tracker | 5 years ago | RichardL
    java.lang.ArrayIndexOutOfBoundsException: 2

    Root Cause Analysis

    1. java.lang.ArrayIndexOutOfBoundsException

      2

      at org.zkoss.zul.SimpleListModel.getElementAt()
    2. ZK XUL Components
      Combobox.syncSelectionToModel
      1. org.zkoss.zul.SimpleListModel.getElementAt(SimpleListModel.java:92)
      2. org.zkoss.zul.Combobox.syncSelectionToModel(Combobox.java:609)
      2 frames