Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-795

Setter for SimpleListModel

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 5.0.9
    • General

      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!

            Unassigned Unassigned
            RichardL RichardL
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: