{
_delegate.handleNavigation(context, fromAction, outcome);
return;
}
RequestContext afc = RequestContext.getCurrentInstance();
// We are interested for "dialog:" prefixed outcomes
if ((outcome != null) && (outcome.startsWith(afc.getDialogService().getDialogNavigationPrefix())))
{
// Handle "dialog:" URLs
// First we try find a classic navigation case from faces-config.xml
NavigationCase navigationCase = getNavigationCase(context, fromAction, outcome);
// Then if there is no rule (but we are in dialog here) try interpret
// outcome as view id - JSF 2.0 Implicit Navigation.
if (navigationCase == null)
{
navigationCase = getNavigationCase(context, fromAction,
outcome.substring(afc.getDialogService().getDialogNavigationPrefix().length()));
}
UIViewRoot newRoot = null;
UIViewRoot oldRoot = context.getViewRoot();
if (navigationCase == null)
{
// Execute the old (pre-ConfigurableNavigation) code in case the navigation case
// could not be determined
// ViewMap is cleared during navigation, so save it here (we will be undoing the navigation
// by restoring the old view root below)
Map<String,Object> viewMap = oldRoot.getViewMap(false);
Map<String,Object> cloneMap = (viewMap == null) ? null : new HashMap<String, Object>(viewMap);
_delegate.handleNavigation(context, fromAction, outcome);
newRoot = context.getViewRoot();
if (newRoot != oldRoot)
{
// Navigate back to the original root
context.setViewRoot(oldRoot);
// Restore the old ViewMap because it gets cleared during setViewRoot()
if (cloneMap != null)
{
oldRoot.getViewMap().putAll(cloneMap);
}
}
}
else
{
newRoot = context.getApplication().getViewHandler().createView(context, navigationCase.getToViewId(context));
}
if (newRoot != oldRoot)
{
// Give ourselves a new page flow scope
afc.getPageFlowScopeProvider().pushPageFlowScope(context, true);
// And ask the component to launch a dialog
afc.getDialogService().queueLaunchEvent(newRoot);
}
}
else
{
// not a dialog, call the wrapped NavigationHandler