简体   繁体   English

gwt中可编辑组合框的值在焦点丢失之前不会更新

[英]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. 我有一个登录视图,其中包含两个用于输入用户名和密码的文本字段,以及一个用于指定要使用的数据库的ComboBox。 To allow other databases than the ones predefined in the combobox I've made it edtiable with setCustomTextAllowed(true). 为了允许使用除组合框中预定义的数据库以外的其他数据库,我使用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. 问题在于,如果组合框的getText()已被手动更改并且尚未失去焦点,则它不会返回组合框的实际值。 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. 我只是意识到这不是标准的GWT组件。 I guess I just read the first part of the package (org.gwt.advanced.client.ui.widget) and assumed it was. 我想我只是阅读了软件包的第一部分(org.gwt.advanced.client.ui.widget)并认为是。 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. 组件上已经有一个Enter处理程序,该处理程序会自动将最后选择的索引值复制到文本字段中。 I also found a way to deactivate this with combobox.setEnterAction(EnterAction.DO_NOTHING); 我还找到了一种使用combobox.setEnterAction(EnterAction.DO_NOTHING)停用此方法的方法; The library in question (i think): advanced-gwt.sourceforge.net 有问题的库(我认为):advanced-gwt.sourceforge.net

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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