[英]GWT List editor binding
public interface Person {
String getName();
void setName(String name);
List<PersonFriend> getFriends();
}
public interface PersonFriend {
String getName();
}
我正在尝试为Person
实现一个只查看编辑器:
public class PersonViewEditor extends Composite implements Editor<Person> {
private static PersonViewEditorUiBinder uiBinder = GWT.create(PersonViewEditorUiBinder.class);
interface PersonViewEditorUiBinder extends UiBinder<Widget, PersonViewEditor> {}
@UiField Label nameEditor;
@UiField PersonFriendsViewEditor friendsEditor;
@UiField FancyAnchor editAnchor;
public PersonViewEditor(ClientFactory clientFactory) {
initWidget(uiBinder.createAndBindUi(this));
editAnchor.setPlace(
clientFactory.getPlaceHistoryMapper(),
clientFactory.getPlaceController(),
new EditPersonPlace());
}
}
public class PersonFriendsViewEditor extends Composite {
private static PersonFriendsViewEditorUiBinder uiBinder = GWT.create(PersonFriendsViewEditorUiBinder.class);
interface PersonFriendsViewEditorUiBinder extends UiBinder<Widget, PersonFriendsViewEditor> {}
interface Driver extends SimpleBeanEditorDriver<List<PersonFriend>, ListEditor<PersonFriend, PersonFriendViewEditor>> {}
private class PersonFriendViewEditorSource extends EditorSource<PersonFriendViewEditor> {
@Override
public PersonFriendViewEditor create(int index) {
PersonFriendViewEditor friend = new PersonFriendViewEditor();
containerPanel.insert(friend, index);
return friend;
}
}
@UiField HorizontalPanel containerPanel;
public PersonFriendsViewEditor() {
initWidget(uiBinder.createAndBindUi(this));
Driver driver = GWT.create(Driver.class);
ListEditor<PersonFriend, PersonFriendViewEditor> editor = ListEditor.of(new PersonFriendViewEditorSource());
driver.initialize(editor);
}
}
当我绑定Person
对象PersonViewEditor
, friendsEditor
永远不会绑定到人的朋友列表。 看起来PersonFriendsViewEditor
应该实现一些魔术接口以允许GWT与它交互,但我找不到任何相关的文档。 在GWT中有dynatablerf示例,但是它们明确地绑定了它们的列表编辑器,我很好奇将它绑定为“外部”对象的一部分,所以我只是将Person
绑定到PersonViewEditor
并且它拥有所有数据/设置所有小部件。
有什么想法吗?
PersonFriendsViewEditor
应该实现IsEditor<ListEditor<PersonFriend, PersonFriendViewEditor>>
- 解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.