if (pool != null && pool.isDeferredNavigationEnabled() &&
processor.isViewPoolStrategyAllowedForThisView(facesContext, root) &&
(PhaseId.INVOKE_APPLICATION.equals(facesContext.getCurrentPhaseId()) ||
PhaseId.APPLY_REQUEST_VALUES.equals(facesContext.getCurrentPhaseId())) )
{
NavigationHandler navigationHandler = application.getNavigationHandler();
if (navigationHandler instanceof ConfigurableNavigationHandler)
{
NavigationCase navigationCase = ((ConfigurableNavigationHandler) navigationHandler).
getNavigationCase(facesContext, fromAction, outcome);
if (navigationCase != null)
{
// Deferred invoke navigation. The first one wins
if (!facesContext.getAttributes().containsKey(ViewPoolProcessor.INVOKE_DEFERRED_NAVIGATION))
{
String toFlowDocumentId = (component != null) ?
(String) component.getAttributes().get(ActionListener.TO_FLOW_DOCUMENT_ID_ATTR_NAME) : null;
if (toFlowDocumentId != null)
{
facesContext.getAttributes().put(ViewPoolProcessor.INVOKE_DEFERRED_NAVIGATION,
new Object[]{fromAction, outcome, toFlowDocumentId});
}
else
{
facesContext.getAttributes().put(ViewPoolProcessor.INVOKE_DEFERRED_NAVIGATION,
new Object[]{fromAction, outcome});
}
}
}
}
}
else
{
NavigationHandler navigationHandler = application.getNavigationHandler();
String toFlowDocumentId = (component != null) ?
(String) component.getAttributes().get(ActionListener.TO_FLOW_DOCUMENT_ID_ATTR_NAME) : null;
if (toFlowDocumentId != null)
{
navigationHandler.handleNavigation(facesContext, fromAction, outcome, toFlowDocumentId);
}
else
{
navigationHandler.handleNavigation(facesContext, fromAction, outcome);
}
//Render Response if needed
facesContext.renderResponse();
}
}