0

我有一个 SimpleBeanEditorDriver 来编辑我的帐户 bean,但是当我编辑和调用 flush() 时,我总是得到空值。我检查了所有内容,谷歌文档,stackoverflow,谷歌群组,但没有发现任何问题。我错过了什么 ?

这是我的看法

public class AccountCreatorViewImpl extends Composite {


  interface Driver extends SimpleBeanEditorDriver<Account, AccountEditor> {
  }

  interface AccountCreatorViewImplUiBinder extends UiBinder<HTMLPanel, AccountCreatorViewImpl> {
  }


  Driver driver = GWT.create(Driver.class);

  private static AccountCreatorViewImplUiBinder ourUiBinder = GWT.create(AccountCreatorViewImplUiBinder.class);


  private AccountCreatorPresenter presenter;


  @UiField
  AccountEditor accountEditor;

  @UiField
  Button create;

  public AccountCreatorViewImpl() {

    HTMLPanel rootElement = ourUiBinder.createAndBindUi(this);

    initWidget(rootElement);

    Account account = new Account();

    driver.initialize(accountEditor);


    driver.edit(account);


  }

  @UiHandler("create")
  public void onCreate(ClickEvent event) {


    Account editedAccount = driver.flush();
    if (driver.hasErrors()) {

      Window.alert("Has errors! ->"+driver.getErrors().toString());
    }

    Window.alert(editedAccount.getEmail() + "/" + editedAccount.getPassword());

//    presenter.create(editedAccount);
  }


} 

这是我的简单编辑器

public class AccountEditor extends Composite implements Editor<Account> {


  interface AccountEditorUiBinder extends UiBinder<HTMLPanel, AccountEditor> {
  }

  private static AccountEditorUiBinder ourUiBinder = GWT.create(AccountEditorUiBinder.class);

  @UiField
  TextBox email;

  @UiField
  PasswordTextBox password;

  public AccountEditor() {

    HTMLPanel rootElement = ourUiBinder.createAndBindUi(this);

    initWidget(rootElement);


  }

}

这是我的帐户类帐户

public class Account implements Serializable {


  private String email;

  private String password;

  public Account(String email) {
    this.email = email;
  }

  public Account() {

  }

  public Account(String email, String password) {

    this.email = email;
    this.password = password;
  }


  public String getEmail() {
    return email;
  }

  public String getPassword() {
    return password;
  }
}

我的应用程序中的另一个编辑器也有同样的问题。实际上两者都不起作用。当我按下保存或创建时,我得到实体的空值。

4

1 回答 1

2

Try adding setEmail() and setPassword() methods to your account class

于 2012-06-13T12:08:20.063 回答