return;
}
String viewId = facesContext.getViewRoot().getViewId();
Map casesMap = getNavigationCases(facesContext);
NavigationCase navigationCase = null;
List casesList = (List)casesMap.get(viewId);
if (casesList != null)
{
// Exact match?
navigationCase = calcMatchingNavigationCase(casesList, fromAction, outcome);
}
if (navigationCase == null)
{
// Wildcard match?
List keys = getSortedWildcardKeys();
for (int i = 0, size = keys.size(); i < size; i++)
{
String fromViewId = (String)keys.get(i);
if (fromViewId.length() > 2)
{
String prefix = fromViewId.substring(0, fromViewId.length() - 2);
if (viewId.startsWith(prefix))
{
casesList = (List)casesMap.get(fromViewId);
if (casesList != null)
{
navigationCase = calcMatchingNavigationCase(casesList, fromAction, outcome);
if (navigationCase != null) break;
}
}
}
else
{
casesList = (List)casesMap.get(fromViewId);
if (casesList != null)
{
navigationCase = calcMatchingNavigationCase(casesList, fromAction, outcome);
if (navigationCase != null) break;
}
}
}
}
if (navigationCase != null)
{
if (log.isTraceEnabled())
{
log.trace("handleNavigation fromAction=" + fromAction + " outcome=" + outcome +
" toViewId =" + navigationCase.getToViewId() +
" redirect=" + navigationCase.isRedirect());
}
if (navigationCase.isRedirect() &&
(!PortletUtil.isPortletRequest(facesContext)))
{ // Spec section 7.4.2 says "redirects not possible" in this case for portlets
ExternalContext externalContext = facesContext.getExternalContext();
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
String redirectPath = viewHandler.getActionURL(facesContext, navigationCase.getToViewId());
Object req = externalContext.getRequest();
if (req instanceof HttpServletRequest)
{
String queryString = ((HttpServletRequest)req).getQueryString();
if (queryString != null)
{
if (redirectPath.indexOf('?') == -1)
{
redirectPath = redirectPath + '?' + queryString;
}
else
{
redirectPath = redirectPath + '&' + queryString;
}
}
}
try
{
externalContext.redirect(externalContext.encodeActionURL(redirectPath));
}
catch (IOException e)
{
throw new FacesException(e.getMessage(), e);
}
facesContext.responseComplete();
}
else
{
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
//create new view
UIViewRoot viewRoot = viewHandler.createView(facesContext, navigationCase.getToViewId());
facesContext.setViewRoot(viewRoot);
facesContext.renderResponse();
}
}
else