public interface Person {
String getName();
void setName(String name);
List<PersonFriend> getFriends();
}
public interface PersonFriend {
String getName();
}
I'm trying to implement a view-only editor for 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);
}
}
When I bind Person
object to PersonViewEditor
, friendsEditor
is never bound to person's friends list. It looks like PersonFriendsViewEditor
should implement some magic interface to allow GWT interact with it, but I can't find any related docs. There's dynatablerf example in GWT, but they bind their list editor explicitly and I'm curious about binding it as a part of "outer" object, so I just bind Person
to PersonViewEditor
and it has all the data/sets all the widgets.
Any thoughts?
PersonFriendsViewEditor
should implement IsEditor<ListEditor<PersonFriend, PersonFriendViewEditor>>
- that resolved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With