-
Notifications
You must be signed in to change notification settings - Fork 2
GWT Integration Editor
The gwt-integration-editor library helps to deal with the Editor framework of GWT.
This is a powerful tool, however it poses several problems about integration with RequestFactory and has a small number of widgets that support its signature.
- Editor and RequestFactory are difficult to manage together
- Editor and RequestFactory are difficult to manage when creating a search page with filters
- Most of the widgets cannot be used with a ValueBoxEditorDecorator
The problem: When you have to create an edit page for a class that extends EntityProxy, it's very difficult to manage message sending to the server, validation errors, object reuse.
The solution: Extends EditorWorkflow, because it contains all the boring and repetitive part about saving, deleting, validation checking, object reuse.
Be sure that your request implements the CrudRequest interface.
Supposing that you are using MVP framework, in your activity define the driver (interface and field) and an EditorWorkflow. For example:
interface Driver extends RequestFactoryEditorDriver<PersonProxy, PersonEditor> {};
private Driver driver;
private EditorWorkflow<PersonProxy, PersonRequest, PersonEditor, Long> workflow;
In the constructor, create the driver and the workflow (with its definition). For example:
driver = GWT.create(Driver.class);
workflow = new EditorWorkflow<PersonProxy, PersonRequest, PersonEditor, Long>(requestFactory, driver, clientFactory.getPersonDetailView().getEditor()) {
@Override
protected PersonRequest getNewRequestContext() {
return PersonDetailActivity.this.requestFactory.personRequest();
}
@Override
protected Class<PersonProxy> getEntityProxyClass() {
return PersonProxy.class;
}
@Override
protected Long getEntityId(PersonProxy entityProxy) {
return entityProxy.getId();
}
@Override
protected void afterSave(PersonProxy response) {
Window.alert("Save successful!");
goTo(new PersonDetailPlace(response.getId()));
}
@Override
protected void afterDelete() {
Window.alert("Delete successful!");
goTo(new ListPersonsPlace());
}
};
Connect the start method by calling the workflow.start method and prepare a method for saving and a method for deleting in your presenter/activity. For example:
@Override
public void start(final AcceptsOneWidget panel, EventBus eventBus) {
PersonDetailView view = clientFactory.getPersonDetailView();
view.setPresenter(this);
view.canDelete(id != null);
panel.setWidget(view);
workflow.start(id);
}
@Override
public void save() {
workflow.save();
}
@Override
public void delete() {
workflow.delete();
}
The problem: Using a ValueProxy, corresponding to a DTO class on the server side, is very useful when creating search pages with a complex filter. However, managing it with the Editor Framework and RequestFactory leads to problems regarding validation, message sending, object reuse.
The solution: TODO WHEN WE HAVE AN EXAMPLE IN THE ARCHETYPE.
The problem: There are few widgets that can be wrapped in the very useful ValueBoxEditorDecorator, to show the error next to the field that caused it.
The solution: TODO WHEN WE HAVE AN EXAMPLE IN THE ARCHETYPE.