spring-vaadin
spring-vaadin copied to clipboard
DiscoveryNavigator.setErrorView(MyView.class) does not handle error correctly
Hi, if I set my error view with setErrorView(MyView.class), when Navigator has to redirect to the error view, it creates a new instance of MyView.class instead of getting the autowired view as expected.
Here's my workaround: navigator.setErrorProvider(new ViewProvider() { private static final long serialVersionUID = 1L;
@Override
public String getViewName(String viewAndParameters) {
return ErrorView.NAME;
}
@Override
public View getView(String viewName) {
String errorViewBeanName = SpringApplicationContext.getApplicationContext().getBeanNamesForType(ErrorView.class)[0];
VaadinView vaadinView = (VaadinView) ErrorView.class.getAnnotation(VaadinView.class);
return ( (DiscoveryNavigator) navigator ).getView(ErrorView.NAME, errorViewBeanName, vaadinView.cached());
}
});