简体   繁体   中英

value of editable combobox in gwt isn't updated until focus is lost

I have a login view containing two textfields for user name and password and one ComboBox specifying which database to use. To allow other databases than the ones predefined in the combobox I've made it edtiable with setCustomTextAllowed(true). Each input has a enter handler attached to it to generate a click on the login button. The click handler of this button uses the values of the fields and combobox to make a server call:

login(txtUser.getText(), txtPwd.getText(), cboDatabase.getText())

The problem is that the getText() for the combobox doesn't return the actual value of the combobox if it's been changed manually and not yet lost focus. It's as if the value of the combobox isn't written to the model until it loses focus. Instead, It returns the latest predefined value selected in the combobox. How do I make sure the database value will be the one the user sees?

I just realized this is not a standard GWT component. I guess I just read the first part of the package (org.gwt.advanced.client.ui.widget) and assumed it was. I also found the problem; there's already an enter handler attached to the component that automatically copies the value of the last selected index to the textfield. I also found a way to deactivate this with combobox.setEnterAction(EnterAction.DO_NOTHING); The library in question (i think): advanced-gwt.sourceforge.net

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM