When you want to edit a new instance (regardless if its an "empty" instance or not) you would create a new editor driver and call edit() with the new instance. As the editor graph represents more or less your object graph this should be enough to update the Ui. If the instance is "empty" the Ui should be "empty" as well after calling edit(). I guess thats why there is no clear() method.
+1 except you don't have to create a new editor driver, you can reuse a previously built one.
+1 except you don't have to create a new editor driver, you can reuse a previously built one.Wasn't there a memory leak somewhere in the editor framework when you reuse the driver? That was somewhere in my head while answering. But maybe its already solved.
This is how I usually do it (not sure if this is the best approach).
In my View:
public class AccountDetailView {
public interface AccountDisplayDriver extends RequestFactoryEditorDriver<AccountProxy, AccountDisplayEditor> {}
@UiField AccountDisplayEditor accountDisplayEditor;
private final AccountDisplayDriver displayDriver;
@Inject
public AccountDetailView(final Binder binder, final AccountDisplayDriver displayDriver) {
widget = binder.createAndBindUi(this);
this.displayDriver = displayDriver;
this.displayDriver.initialize(accountDisplayEditor);
}
@Override
public AccountDisplayDriver getDisplayDriver() {
return displayDriver;
}
}
GIN will make sure that GWT.create is called on the Driver interface and from my Presenter I can call getView().getDisplayDriver() to return the driver and interact with it.