NavigationContext navigationContext = new NavigationContext(); NavigationCase navigationCase = null; try navigationContext.finish(facesContext);
private void applyFlowTransition(FacesContext facesContext, NavigationContext navigationContext) { //Apply Flow transition if any // Is any flow transition on the way? if (navigationContext != null && navigationContext.getSourceFlows() != null || (navigationContext.getTargetFlows() != null && !navigationContext.getTargetFlows().isEmpty())) { FlowHandler flowHandler = facesContext.getApplication().getFlowHandler(); for (int i = 0; i < navigationContext.getTargetFlows().size(); i++) { Flow sourceFlow = navigationContext.getSourceFlows().get(i); Flow targetFlow = navigationContext.getTargetFlows().get(i); flowHandler.transition(facesContext, sourceFlow, targetFlow, navigationContext.getFlowCallNodes().get(i), navigationContext.getNavigationCase().getToViewId(facesContext)); sourceFlow = targetFlow; } } }
Flow currentFlow = navigationContext.getCurrentFlow(facesContext); FlowCallNode targetFlowCallNode = null; boolean startFlow = false; Flow baseReturnFlow = navigationContext.getCurrentFlow(facesContext); navigationContext.popFlow(facesContext); baseReturnFlow = navigationContext.getCurrentFlow(facesContext); navigationContext.popFlow(facesContext); currentFlow = navigationContext.getCurrentFlow(facesContext); navigationContext.addTargetFlow(baseReturnFlow, currentFlow, null); navigationContext.addTargetFlow(currentFlow, targetFlow, targetFlowCallNode); targetFlowCallNode = null; navigationContext.pushFlow(facesContext, targetFlow); currentFlow = targetFlow; actionToGo = currentFlow.getId(); Flow sourceFlow = currentFlow; Flow baseReturnFlow = navigationContext.getCurrentFlow(facesContext); navigationContext.popFlow(facesContext); baseReturnFlow = navigationContext.getCurrentFlow(facesContext); navigationContext.popFlow(facesContext); currentFlow = navigationContext.getCurrentFlow(facesContext); navigationContext.addTargetFlow(sourceFlow, currentFlow, null);
/** * Returns the navigation case that applies for the given action and outcome */ public NavigationCase getNavigationCase(FacesContext facesContext, String fromAction, String outcome) { NavigationContext navigationContext = new NavigationContext(); try { return getNavigationCommand(facesContext, navigationContext, fromAction, outcome, null); } finally { navigationContext.finish(facesContext); } }