Delegate an Editor's edit() & save() functionality via Activities & Places' Presenter to an Activity class?

58 views
Skip to first unread message

Alexander Orlov

unread,
Jul 30, 2012, 4:18:44 AM7/30/12
to google-we...@googlegroups.com
I have an architectural question. I've introduced EntityWorkflow to my Activities & Places enabled app. In GWT's Activities & Places there are the Presenter interfaces which is used by a view to delegate the implementation of certain action (like edit() & save()) to the Activities class. So does it make sense to treat an EntityWorkflow as a A&P view and to apply A&P's action delegation feature here? Or to speak code-wise:

public class EntityEditorWorkflow {
    // Empty interface declaration, similar to UiBinder
    interface Driver extends RequestFactoryEditorDriver<EmployeeProxy, EmployeeEditor> {
    }

    private static final Driver driver = GWT.create(Driver.class);

    @UiHandler("save")
    public void onSave(ClickEvent event) {
      // implementing the actual SaveEntity code
    Person edited = driver.flush();
   
if (driver.hasErrors()) {
     
// A sub-editor reported errors
   
}
    doSomethingWithEditedPerson
(edited);

          vs. 

      // ...
      presenter.save(entity);
    }
}

Thomas Broyer

unread,
Jul 30, 2012, 5:54:09 PM7/30/12
to google-we...@googlegroups.com
I generally expose the EditorDriver to the presenter using a createdDriver method on the view. The presenter calls the edit, flush and hasErrors, not the view.

Also note this has nothing to do with Activities, it's MVP.

Reply all
Reply to author
Forward
0 new messages