I read a comment from Ray Ryan to the effect that
an Activity can have multiple Presenters.

does anyone know what is the recommended way to implement this ?

for example the code below is the way
typical Activity has been implemented in examples:

normally the MyActivity has a View

public class MyActivity extends AbstractActivity {

MyView view;

public MyActivity(MyView view, EventBus eventBus){
this.view = view;
//..
}

public void start(AcceptsOneWidget panel, EventBus eventBus){

panel.setWidget(view);
}

}

to implement what Ray Ryan suggested,
I assume our View would have a number of slots (simple panels) that
widgets can be inserted in.
and these Widgets can have corresponding Presenters.

having said these,

do you think it is better to inject the Presenters in the Activity, or
the View ?

lets say our Activity has a Master View, this View has 3 slots which
is going to hold 3 widgets
these widgets have a corresponding presenter

public class MyActivity extends AbstractActivity {

MyPresenterWideget1 presenter1;
MyPresenterWideget2 presenter2;
MyPresenterWideget3 presenter;

MyMasterView view;

@Inject
public MyActivity(MyMasterView view, MyWidegetPresenter1 presenter1,
                         MyWidegetPresenter2 presenter2,
                         MyWidegetPresenter3 presenter3, EventBus
eventBus) {

this.presenter1 = presenter1;
this.presenter2 = presenter2;
this.presenter3 = presenter3;
this.view = view;
this.eventBus = eventBus;
}

public void start(AcceptsOneWidget panel, EventBus){

view.setWidget1(presenter1.getWidget());
view.setWidget2(presenter2.getWidget());
view.setWidget3(presenter3.getWidget())

panel.setWidget(view)
}

}

or is it better to inject Widgets in the Activity

public class MyActivity extends AbstractActivity {

MyWidget1 widget1;
MyWidget2 widget2;
MyWidget3 widget3;

....

public void start(AcceptsOneWidget panel, ..)
view.setWidget(widget1);
view.setWidget2(widget2);
view.setWidget3(widget3);
panel.setWidget(view
}


and are these PresenterWidgets going to communicate through EventBus ?

-- 
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