}
@Override
public void handleNavigation(FacesContext facesContext, String fromAction, String outcome)
{
NavigationCase navigationCase = getNavigationCase(facesContext, fromAction, outcome);
if (navigationCase != null)
{
if (log.isLoggable(Level.FINEST))
{
log.finest("handleNavigation fromAction=" + fromAction + " outcome=" + outcome +
" toViewId =" + navigationCase.getToViewId(facesContext) +
" redirect=" + navigationCase.isRedirect());
}
if (navigationCase.isRedirect())
{
//&& (!PortletUtil.isPortletRequest(facesContext)))
// Spec section 7.4.2 says "redirects not possible" in this case for portlets
//But since the introduction of portlet bridge and the
//removal of portlet code in myfaces core 2.0, this condition
//no longer applies
ExternalContext externalContext = facesContext.getExternalContext();
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
String toViewId = navigationCase.getToViewId(facesContext);
String redirectPath = viewHandler.getRedirectURL(facesContext, toViewId, navigationCase.getParameters(), navigationCase.isIncludeViewParams());
//Clear ViewMap if we are redirecting to other resource
UIViewRoot viewRoot = facesContext.getViewRoot();
if (viewRoot != null && !viewRoot.getViewId().equals(toViewId))
{
//call getViewMap(false) to prevent unnecessary map creation
Map<String, Object> viewMap = viewRoot.getViewMap(false);
if (viewMap != null)
{
viewMap.clear();
}
}
// JSF 2.0 the javadoc of handleNavigation() says something like this
// "...If the view has changed after an application action, call
// PartialViewContext.setRenderAll(true)...". The effect is that ajax requests
// are included on navigation.
PartialViewContext partialViewContext = facesContext.getPartialViewContext();
String viewId = facesContext.getViewRoot() != null ? facesContext.getViewRoot().getViewId() : null;
if ( partialViewContext.isPartialRequest() &&
!partialViewContext.isRenderAll() &&
!toViewId.equals(viewId))
{
partialViewContext.setRenderAll(true);
}
// JSF 2.0 Spec call Flash.setRedirect(true) to notify Flash scope and take proper actions
externalContext.getFlash().setRedirect(true);
try
{
externalContext.redirect(redirectPath);
facesContext.responseComplete();
}
catch (IOException e)
{
throw new FacesException(e.getMessage(), e);
}
}
else
{
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
//create new view
String newViewId = navigationCase.getToViewId(facesContext);
// JSF 2.0 the javadoc of handleNavigation() says something like this
// "...If the view has changed after an application action, call
// PartialViewContext.setRenderAll(true)...". The effect is that ajax requests
// are included on navigation.
PartialViewContext partialViewContext = facesContext.getPartialViewContext();