Combobox sometimes clears the selected item

asked 2017-03-10 14:14:53 +0800

pcrp gravatar image pcrp
1 1

updated 2017-03-10 19:04:49 +0800

We are having some problems with selecting an item on a combobox. Sometimes, when the users selects one of the possible options on the combobox, the selected item is null, but the user’s choice, the value that the selected item should have, has been communicated to the viewmodel and has influenced our forms. For us this an error because the user is choosing an option that exists and then the selection in cleared. We didn’t detect this problem until a few months ago and the number of times this has happened has been increasing.

This are the conditions we have on the project: • Our comboxes are autodroppable and use autocomplete. • The comboboxes have an event listener. When the focus leaves the combobox, if the selected item is null the combobox has to clear the value inputed by the user. It was a request so the user can see that the inputed value wasn’t found on the combobox. o We deleted this behavior to see if it was the cause of the problem and it wasn’t. • The models used for the comboboxes extend the SimpleListModel. o They are initiated with an empty list and everytime the getSubModel method is called, we communicate with the database using a webservice. Also the max number of results our submodels can have is 10. I tried to replicate this problem in the zk-fiddle, it wasn’t very easy, because it doesn’t have the same conditions, the example isn’t using webservices and isn’t communicating with the database, so to emulate a big delay of the webservice I have put a Thread.sleep.

On the example you can see a combobox and a textbox. The selectedItem of the combobox and the value of the textbox are binded to the same property on the viewmodel. If you try different ways to choose the value of combobox (ex: write a character and wait before the second character).

Here is the example: zkfiddle.org/sample/37tfq7f/6-Autocomplete-P

delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted

answered 2017-03-13 09:26:38 +0800

Darksu gravatar image Darksu
1991 1 4

Hello pcrp,

As a tip probably it would be best if you loaded the data from the database at the page load so you will avoid querying the database every time.

Best Regards,


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2017-03-10 14:14:53 +0800

Seen: 38 times

Last updated: Mar 13 '17

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More