gpt4 book ai didi

java - GWT 列表编辑器绑定(bind)

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:26:53 25 4
gpt4 key购买 nike

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 对象绑定(bind)到 PersonViewEditor 时,friendsEditor 永远不会绑定(bind)到人的好友列表。看起来 PersonFriendsViewEditor 应该实现一些神奇的接口(interface)以允许 GWT 与之交互,但我找不到任何相关文档。 GWT 中有 dynatablerf 示例,但它们显式绑定(bind)了列表编辑器,我很好奇将其绑定(bind)为“外部”对象的一部分,所以我只是将 Person 绑定(bind)到 PersonViewEditor 它拥有所有数据/设置所有小部件。

有什么想法吗?

最佳答案

PersonFriendsViewEditor应该实现 IsEditor<ListEditor<PersonFriend, PersonFriendViewEditor>> - 解决了问题。

关于java - GWT 列表编辑器绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7859388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com