Editor and RequestFactory

61 views
Skip to first unread message

Brian Chapman

unread,
Sep 1, 2011, 9:18:50 PM9/1/11
to google-we...@googlegroups.com
I have a question about using the RequestFactoryEditorDriver. I am trying to use the editor with request factory on the client side. On the server side I am using Objectify which is modeled after the listWidget example. I have a ProjectRequest class (implementing RequestContext) that defines a save method. 

My question is how do I invoke the save method from the editor. It appears that after a driver.flush() I only have a RequestContext object to work with. That object only has the fire method, but I cannot tell it to use my save(project) method. When I invoke the requestContext.fire() method after doing a .flush(), the request factory appears to contact the server but nothing is persisted. Are there implied methods that the editor or RequestFactory is expecting to be implemented on the server? Should I be using the SimpleBeanEditorDriver instead?

My Editor: 
public class ProjectEditor extends Composite implements Editor<ProjectProxy> {
    interface Binder extends UiBinder<HTMLPanel, ProjectEditor> { }
    private static Binder uiBinder = GWT.create(Binder.class);
    @UiField
    TextBox name;
    public ProjectEditor() {
      initWidget(uiBinder.createAndBindUi(this));
    }
}
 My workflow class:
public class ProjectAddPresenter extends
        Presenter<ProjectAddPresenter.MyView, ProjectAddPresenter.MyProxy> {
    ...
    interface Driver extends
            SimpleBeanEditorDriver<ProjectProxy, ProjectEditor> {}
    @Inject private CommonRequestFactory commonRf;
    private Driver driver;
    @Inject
    public ProjectAddPresenter(final EventBus eventBus,
            final MyView view,
            final MyProxy proxy) {
        super(eventBus, view, proxy);
        this.view = view;
        view.setPresetner(this);
        driver = GWT.create(Driver.class);
    }
    ...
    public void edit() {
        ProjectRequest request = commonRf.projectRequest();
        ProjectProxy project = request.create(ProjectProxy.class);
        ProjectEditor pe = view.getProjectEditor();
        driver.initialize(pe);
        driver.edit(project, request);
    }
    public void createProject(ProjectEditor projectEditor) {
        RequestContext request = driver.flush();
        request.fire(new Receiver<Void>() {
            ...
        });
    }
    ...
}
My ProjectRequest class:
@Service(value = ProjectDao.class, locator = DaoServiceLocator.class)
public interface ProjectRequest extends RequestContext {
  ...
  Request<Void> save(ProjectProxy project);
  ...
}
 Thank you.
 

Daniel Guggi

unread,
Sep 2, 2011, 3:09:28 AM9/2/11
to google-we...@googlegroups.com
like this?


public void edit() {
        ProjectRequest request = commonRf.projectRequest();
        ProjectProxy project = request.create(ProjectProxy.class);
        request.save(project).to(new Receiver<Void>() {

           ...
        });

        ProjectEditor pe = view.getProjectEditor();
        driver.initialize(pe);
        driver.edit(project, request);
    }


    public void createProject(ProjectEditor projectEditor) {
        RequestContext request = driver.flush();
        request.fire();
    }



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/qpOhqiJGc4sJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Brian Chapman

unread,
Sep 2, 2011, 12:00:54 PM9/2/11
to google-we...@googlegroups.com
Thanks! I didn't realize that you could issue a save before the proxy was even edited. I guess the RequestContext is more like a queuing system than a procedural list of instructions.
Reply all
Reply to author
Forward
0 new messages