Typed Slots

50 views
Skip to first unread message

itd: Michael Kaulig

unread,
Dec 1, 2015, 9:03:11 AM12/1/15
to gwt-pl...@googlegroups.com
Hi,

I build some presenter widget, which has one slot for a navigation presenter widget. Since I have different widgets for navigation I have to use a general type for the generic parameter of the slot for the navigation widget.

Here is the problem:
Since IsSlot has the generic type <T extends PresenterWidget<?>> and PresenterWidget is a class not an interface I see two options:

1. Use a (abstract) super class Navigation for all the navigation presenters which extends PresenterWidget<NavigationView>. Now all my Views and Presenter Widgets need to Inherit from NavigationPresenter and NavigationView, which hinders reuse of these widgets in other contexts.

2. Let all Navigation Presenters implement some interface INavigationPresenter which specifies the methods supported by all navigation widgets. The problem here is that this interface needs to have some method PresenterWidget asPresenterWidget() to get the actual implementation and put it into the slot. Here I loose the type information, because I have to return PresenterWidget<?>, which seems to destroy the whole typed slots concept.

What is the best practice here? Is there a third solution to keep the class hierarchy clean and keep the type information of the slots?

Is there a reason why IsSlot does not have a generic type of something like <T extends IsPresenterWidget> where IsPresenterWidget would be some Interface implemented by PresenterWidget (like the GWT Widget which implements IsWidget)?

Kind regards,
Michael


Renaud Lainé

unread,
Dec 14, 2015, 5:04:54 PM12/14/15
to GWTP, Michael...@itdesign.de
Hi Michael,

The third option would be to declare your slot without any generic type:

static Slot SLOT_XYZ = new Slot();
Reply all
Reply to author
Forward
0 new messages