I use GWT on client side with activities&places. I got a layout (LeftSide - CenterSide - RightSide), and each side got it's own ActivityMapper + Activity + View.
I would like to add dynamically Views(With activity) to Sides. For Example if user's gender is male, then on left side display the AView+APresenter , and BView+BPresenter; but if user's gender is female display only BView+BPresenter.
Can anobody help me about how can I do that?
Thanks
You have to create a fourth ActivityMapper
that returns null
when needed.
Its display region (AcceptsOneWidget
) can possibly shrink/disappear when passed a null
widget.
See http://blog.ltgt.net/gwt-21-activities-nesting-yagni/ for more context and some sample code.
However, if you're varying depending on the user, and do the authentication outside your app (meaning the app is loaded with a known user and it then never changes, or the app is reloaded with for other user), then you can simply decide at startup (onModuleLoad
) whether to create that fourth ActivityMapper
along with its ActivityManager
and AcceptsOneWidget
:
if (user.getGender() == Gender.MALE) {
SimplePanel display = new SimplePanel();
parent.add(display);
ActivityManager manager = new ActivityManager(new MaleSpecificActivityMapper(), eventBus);
manager.setDisplay(display);
}