我无法使用Bindings和带有2个字段的BaseModelData从FramedPanel检索数据。谁能告诉我出了什么问题.. 我也尝试过和编辑选项,但它根本没有将数据绑定到UI ..
Map<String, Object> map = new HashMap<String, Object>();
BaseModelData baseModelData;
FramedPanel formPanel;
Bindings bindings;
User user = new User();
public Widget getLoginForm(){
TextField textField = new TextField();
textField.setHeight(10);
textField.addValidator(new EmptyValidator<String>());
textField.setName("userId");
PasswordField passwordField = new PasswordField();
passwordField.setName("password");
VBoxLayoutContainer boxLayoutContainer = new VBoxLayoutContainer(VBoxLayoutAlign.CENTER);
boxLayoutContainer.add(new FieldLabel(textField,"User Id"));
boxLayoutContainer.add(new FieldLabel(passwordField, "Password"));
map.put("userId", "asd");
map.put("password", "");
formPanel = new FramedPanel();
formPanel.add(boxLayoutContainer);
bindings = new Bindings();
bindings.addFieldBinding(new FieldBinding(textField,"userId"));
bindings.addFieldBinding(new FieldBinding(passwordField,"password"));
baseModelData = new BaseModelData();
baseModelData.setProperties(map);
bindings.bind(baseModelData);
TextButton b = new TextButton("Login");
b.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
Info.display("User Id : ", baseModelData.get("password").toString());
}
});
formPanel.addButton(b);
}
答案 0 :(得分:0)
您应该使用GWT编辑器框架进行数据绑定。
查看Sencha的文档:
http://docs.sencha.com/gxt-guides/3/data/editors/Editors.html
使用Bindings和BaseModelData类是旧样式的GXT。它是遗留包的一部分,应该有助于迁移现有项目。如果你用GXT 3开始一个新项目,我建议使用GWT编辑器框架。