-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
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 Richard
Hi terrytornado,
Sorry if I wasn't clear. My point was that there is no setter for data in SimpleListModel and for cases where the data is reset in getSubModel, there should be. I could be wrong and there may be some workaround, but if not I'll make a feature request.
Hi Richard, the zk guys will read this. But a feature request will be saver, you are right :-)
Thanks, Matze2. I made a feature request: http://tracker.zkoss.org/browse/ZK-795. Happy Chinese New Year! :)
Asked: 2012-01-25 05:04:31 +0800
Seen: 576 times
Last updated: Jan 26 '12