Hello all.
I Have a simple scenario:
-a GWT application with an application controller that handles history
and initialize modules. ( a module is an entity formed by a presenter
+ view - classic MVP, nothing special)
-from a module should be opened another module and pass init data to
it, and then after child module finishes its job to return another
response data.

I followed two approaches and i would like to comment them.

1.eventBuss approach - pass data within events.
i have StartChildModuleEvent event that encapsulates a module parent
ID, and some init data, and an ExitChildModuleEvent event that
encapsulates some return data.


2 callback approach.
i added to my modules a callBack handler


public abstract class ModuleCallBackHandler<D, T> implements
DataCallBackHandler<T> {

  private ModuleID parentID;

  private D initData;
  private T returnData;

  public ModuleCallBackHandler(ModuleID parentID) {
    this.parentID = parentID;
  }

  public ModuleCallBackHandler(ModuleID parentID, D initData) {
    this.parentID = parentID;
    this.initData = initData;
  }

  public void onCancel(){
  }

  public void onFailure(Throwable caught){
    Window.alert(AppGin.injector.getAppConstants().msg_moduleError() +
" : " + caught.getMessage());
//    caught.printStackTrace();
  }

  public ModuleID getParentID() {
    return parentID;
  }

  public D getInitData() {
    return initData;
  }

  public T getReturnData() {
    return returnData;
  }

}


and when i want to init a child module i instantiate a new callback

AppGin.injector.getAppController().doStartChildModule(ModuleID.ITEMSEARCH,
            new ModuleCallBackHandler<String, Item>(getModuleID(),
itemID) {

              @Override
              public void onSuccess(Item result) {
                //do some stuff - update this module with received
data
              }

            });

I would like some opinions regarding this two approaches.

Thanks all

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to