use of javax.faces.application.NavigationCase in project deltaspike by apache.
the class DeltaSpikeNavigationHandler method getNavigationCase.
@Override
public NavigationCase getNavigationCase(FacesContext context, String action, String outcome) {
if (this.wrapped instanceof ConfigurableNavigationHandler) {
if (!this.activated) {
return ((ConfigurableNavigationHandler) this.wrapped).getNavigationCase(context, action, outcome);
}
if (action == null && outcome != null && outcome.contains(".") && outcome.startsWith("class ") && !otherOutcomes.contains(outcome)) {
String originalOutcome = outcome;
NavigationCase navigationCase = this.viewConfigBasedNavigationCaseCache.get(originalOutcome);
if (navigationCase != null) {
return navigationCase;
}
outcome = outcome.substring(6);
ViewConfigDescriptor entry = null;
if (DefaultErrorView.class.getName().equals(originalOutcome)) {
ViewConfigResolver viewConfigResolver = JsfUtils.getViewConfigResolver();
entry = viewConfigResolver.getDefaultErrorViewConfigDescriptor();
}
if (entry == null) {
Object loadedClass = ClassUtils.tryToLoadClassForName(outcome);
if (loadedClass == null) {
this.otherOutcomes.add(originalOutcome);
} else if (ViewConfig.class.isAssignableFrom((Class) loadedClass)) {
entry = JsfUtils.getViewConfigResolver().getViewConfigDescriptor((Class<? extends ViewConfig>) loadedClass);
}
}
if (entry != null) {
View.NavigationMode navigationMode = entry.getMetaData(View.class).iterator().next().navigation();
navigationCase = new NavigationCase("*", null, null, null, entry.getViewId(), null, View.NavigationMode.REDIRECT.equals(navigationMode), false);
this.viewConfigBasedNavigationCaseCache.put(originalOutcome, navigationCase);
return navigationCase;
}
}
return ((ConfigurableNavigationHandler) this.wrapped).getNavigationCase(context, action, outcome);
}
return null;
}
use of javax.faces.application.NavigationCase in project deltaspike by apache.
the class NavigationCaseMapWrapper method createViewConfigBasedNavigationCases.
private Map<String, Set<NavigationCase>> createViewConfigBasedNavigationCases(boolean allowParameters) {
Map<String, Set<NavigationCase>> result;
if (this.wrapped instanceof ConfigurableNavigationHandler) {
result = new DelegatingMap((ConfigurableNavigationHandler) this.wrapped);
} else {
LOG.warning("the wrapped navigation-handler doesn't extend " + ConfigurableNavigationHandler.class.getName() + ". therefore std. navigation-rules might not work correctly with mojarra");
result = new HashMap<String, Set<NavigationCase>>();
}
Collection<ViewConfigDescriptor> viewConfigDescriptors = BeanProvider.getContextualReference(ViewConfigResolver.class).getViewConfigDescriptors();
if (!viewConfigDescriptors.isEmpty()) {
Set<NavigationCase> navigationCase = new HashSet<NavigationCase>();
Map<String, List<String>> parameters = null;
if (allowParameters) {
parameters = resolveParameters();
}
boolean includeParameters;
for (ViewConfigDescriptor entry : viewConfigDescriptors) {
View viewMetaData = entry.getMetaData(View.class).iterator().next();
includeParameters = View.ViewParameterMode.INCLUDE.equals(viewMetaData.viewParams());
navigationCase.add(new NavigationCase("*", null, null, null, entry.getViewId(), includeParameters ? parameters : null, View.NavigationMode.REDIRECT.equals(viewMetaData.navigation()), includeParameters));
result.put(entry.getViewId(), navigationCase);
}
}
return result;
}
Aggregations