Skip to content

Commit

Permalink
Fix Navigator StateManager autodetection (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuoanttila authored Dec 12, 2017
1 parent 5735ffc commit 89554c5
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void init(UI ui, SingleComponentContainer container) {
* navigator
*/
public void init(UI ui, ViewDisplay display) {
init(ui, new UriFragmentManager(ui.getPage()), display);
init(ui, null, display);
}

/**
Expand Down Expand Up @@ -238,22 +238,28 @@ public void init(UI ui, NavigationStateManager stateManager,
*/
@Override
public void setErrorView(final Class<? extends View> viewClass) {
if(viewClass == null) {
if (viewClass == null) {
setErrorProvider(null);
return;
}
String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(getWebApplicationContext(), viewClass);
String[] beanNames = BeanFactoryUtils
.beanNamesForTypeIncludingAncestors(getWebApplicationContext(),
viewClass);
/*
Beans count==0 here means fallback into direct class instantiation
No need to check for the scope then
*/
* Beans count==0 here means fallback into direct class instantiation No
* need to check for the scope then
*/
if (beanNames.length > 1) {
throw new NoUniqueBeanDefinitionException(viewClass);
} else if (beanNames.length == 1) {
BeanDefinition beanDefinition = viewProvider.getBeanDefinitionRegistry().getBeanDefinition(beanNames[0]);
BeanDefinition beanDefinition = viewProvider
.getBeanDefinitionRegistry()
.getBeanDefinition(beanNames[0]);
String scope = beanDefinition.getScope();
if (!UIScopeImpl.VAADIN_UI_SCOPE_NAME.equals(scope) && ! "prototype".equals(scope)) {
throw new BeanDefinitionValidationException("Error view must have UI or prototype scope");
if (!UIScopeImpl.VAADIN_UI_SCOPE_NAME.equals(scope)
&& !"prototype".equals(scope)) {
throw new BeanDefinitionValidationException(
"Error view must have UI or prototype scope");
}
}

Expand Down Expand Up @@ -283,7 +289,7 @@ public String getViewName(String navigationState) {
}
});
}

protected ApplicationContext getWebApplicationContext() {
if (applicationContext == null) {
// Assume we have serialized and deserialized and Navigator is
Expand All @@ -300,5 +306,4 @@ protected ApplicationContext getWebApplicationContext() {
return applicationContext;
}


}

0 comments on commit 89554c5

Please sign in to comment.