peholmst/MVP4Vaadin — Issue #20: Patch for AbstractView
Author: philippgas
Created: 2012-02-03 15:27:09+00:00
State: open

Hi,

here's a replacement for AbstractView.createPresenter(), which uses reflection to determine and create the Presenter

@Override
public P createPresenter() {

ParameterizedType thisType = (ParameterizedType) getClass().getGenericSuperclass();

@SuppressWarnings("unchecked")
Class

presenterClazz = (Class

) thisType.getActualTypeArguments()[1];

try {
Constructor

ctor = presenterClazz.getConstructor();
return ctor.newInstance();
} catch (NoSuchMethodException e) {
throw new UnsupportedOperationException(
"No default constructor for Presenter '" + presenterClazz.getSimpleName() + "' available.");
}
catch (Exception e) {
throw new RuntimeException(e);
}
}