spring-vaadin icon indicating copy to clipboard operation
spring-vaadin copied to clipboard

DiscoveryNavigator.setErrorView(MyView.class) does not handle error correctly

Open AdrienC opened this issue 11 years ago • 0 comments

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());
        }
    });

AdrienC avatar Jul 01 '13 10:07 AdrienC