View Full Version : Pressing "enter" in field to submit form causes field's BaseModel not to be updated

5 May 2010, 3:18 PM
I'm using FormBinding to bind fields on a page to a BaseModel object, and also using a KeyNav to capture the Enter key press in order to submit the page on enter. If I hit "enter" when the focus is still inside the field (without leaving focus from the field), the field value is not updated into the BaseModel object. It looks like FieldBinding.bind() is triggered by an onBlur event, so if I his "enter" without ever leaving the field, the value from the field is not updated into the bound model object. If I click outside of the field and back into the field, then it works.

How should I handle this issue?

public void onModuleLoad() {

FormPanel formPanel = new FormPanel();
TextField<String> name = new TextField<String>();


final BaseModel model = new BaseModel();
FormBinding formBinding = new FormBinding(formPanel, true);

new KeyNav<ComponentEvent>(formPanel) {
public void onEnter(ComponentEvent ce) {
Window.alert((String) model.get("username"));