private void generateKeyForCDIBeansBelongToAFlow(FacesContext facesContext, Flow flow, int flowDepth) { if (null != flow) { ClientWindow curWindow = facesContext.getExternalContext().getClientWindow(); if (null == curWindow) { throw new IllegalStateException("Unable to obtain current ClientWindow. Is the ClientWindow feature enabled?"); } final String clientWindow = flow.getClientWindowFlowId(curWindow); flowBeansForClientWindowKey = clientWindow + ":" + flowDepth + "_beans"; creationalForClientWindowKey = clientWindow + ":" + flowDepth + "_creational"; } else { flowBeansForClientWindowKey = creationalForClientWindowKey = null; } }
@Override public void doAfterEnterFlow(FacesContext facesContext, Flow flow) { // Reset current flow scope map String mapKey = CURRENT_FLOW_SCOPE_MAP+SEPARATOR_CHAR+ flow.getDefiningDocumentId()+SEPARATOR_CHAR+flow.getId(); facesContext.getAttributes().remove(mapKey); }
if ((this.id == null) ? (other.getId() != null) : !this.id.equals(other.getId())) { return false; if ((this.startNodeId == null) ? (other.getStartNodeId() != null) : !this.startNodeId.equals(other.getStartNodeId())) { return false; if (this._views != other.getViews() && (this._views == null || !this._views.equals(other.getViews()))) { return false; if (this._returns != other.getReturns() && (this._returns == null || !this._returns.equals(other.getReturns()))) { return false; if (this.initializer != other.getInitializer() && (this.initializer == null || !this.initializer.equals(other.getInitializer()))) { return false; if (this.finalizer != other.getFinalizer() && (this.finalizer == null || !this.finalizer.equals(other.getFinalizer()))) { return false;
private String resolveStartNodeOutcome(Flow targetFlow) { String outcomeToGo; if (targetFlow.getStartNodeId() == null) { // In faces-config javadoc says: // "If there is no <start-node> element declared, it // is assumed to be <flowName>.xhtml." outcomeToGo = "/" + targetFlow.getId()+ "/" + targetFlow.getId() + ".xhtml"; } else { outcomeToGo = targetFlow.getStartNodeId(); } return outcomeToGo; }
private void initializeNavigationFromFlowNonThreadSafe(Flow toInspect) { String fullyQualifiedFlowId = toInspect.getDefiningDocumentId() + toInspect.getId(); // Is there an existing NavigationMap for this flowId if (navigationMaps.containsKey(fullyQualifiedFlowId)) { if (logger.isLoggable(Level.INFO)) { logger.log(Level.INFO, "PENDING(edburns): merge existing map"); } } else { Map<String, Set<NavigationCase>> navRules = toInspect.getNavigationCases(); Map<String, SwitchNode> switches = toInspect.getSwitches(); if (!navRules.isEmpty() || !switches.isEmpty()) { NavigationInfo info = new NavigationInfo(); if (!switches.isEmpty()) { info.switches = new ConcurrentHashMap<String, SwitchNode>(); for (Map.Entry<String, SwitchNode> cur : switches.entrySet()) { info.switches.put(cur.getKey(), cur.getValue()); } } if (!navRules.isEmpty()) { info.ruleSet = new NavigationMap(); info.ruleSet.putAll(navRules); } navigationMaps.put(fullyQualifiedFlowId, info); } } }
if (flowHandler.isActive(facesContext, targetFlow.getDefiningDocumentId(), targetFlow.getId())) FlowNode flowNode = targetFlow.getNode(outcome); if (flowNode != null) FlowNode node = activeFlow.getNode(outcome); if (node != null) activeFlow.getId()); navigationCase = getNavigationCaseFromFlowStructure(facesContext, flowNavigationStructure, fromAction, outcome, viewId); if (flowHandler.isActive(facesContext, targetFlow.getDefiningDocumentId(), targetFlow.getId()) && targetFlowCallNode == null) while (baseReturnFlow != null && !(baseReturnFlow.getDefiningDocumentId().equals( targetFlow.getDefiningDocumentId()) && baseReturnFlow.getId().equals(targetFlow.getId())) ) startFlowDocumentId = targetFlow.getDefiningDocumentId(); startFlowId = targetFlowCallNode == null ? targetFlow.getId() : targetFlowCallNode.getId(); FlowNode flowNode = currentFlow.getNode(outcomeToGo); if (flowNode != null) actionToGo = currentFlow.getId(); flowNode = currentFlow.getNode(outcomeToGo); continue;
FlowNode node = currentFlow.getNode(fromOutcome); if (node instanceof ReturnNode) toFlowDocumentId = currentFlow.getDefiningDocumentId(); targetFlows.add(currentFlow); toFlowDocumentId = currentFlow.getDefiningDocumentId(); targetFlows.add(currentFlow); node = activeFlow != null ? activeFlow.getNode(flowIdRequestParam) : null; if (node != null && node instanceof FlowCallNode) calledFlowDocumentId = activeFlow.getDefiningDocumentId(); if (flowHandler.isActive(context, targetFlow.getDefiningDocumentId(), targetFlow.getId())) if (!(baseReturnFlow.getDefiningDocumentId().equals(targetFlow.getDefiningDocumentId()) && baseReturnFlow.getId().equals(targetFlow.getId()))) String startNodeId = targetFlow.getStartNodeId(); while (startNodeId != null && !failed) startNodeId, targetFlow.getDefiningDocumentId()); node = currentFlow.getNode(navCase.getFromOutcome()); if (node != null && node instanceof FlowCallNode) calledFlowDocumentId = currentFlow.getDefiningDocumentId();
private CaseStruct findViewNodeMatch(FacesContext context, String fromAction, String outcome) { FlowHandler flowHandler = context.getApplication().getFlowHandler(); if (null == flowHandler) { return null; } CaseStruct result = null; Flow currentFlow = flowHandler.getCurrentFlow(context); if (null != currentFlow) { FlowNode node = currentFlow.getNode(outcome); if (null != node && node instanceof ViewNode) { result = synthesizeCaseStruct(context, currentFlow, fromAction, outcome); } } if (null != result) { result.currentFlow = currentFlow; result.newFlow = currentFlow; result.facesFlowCallNode = null; } return result; }
FlowCallNode facesFlowCallNode = null; if (null != currentFlow) { FlowNode node = currentFlow.getNode(outcome); if (node instanceof FlowCallNode) { facesFlowCallNode = (FlowCallNode) node; newFlow = flowHandler.getFlow(context, flowDocumentId, flowId); if (null != newFlow) { String startNodeId = newFlow.getStartNodeId(); result = synthesizeCaseStruct(context, newFlow, fromAction, startNodeId); if (null == result) { String startNodeId = newFlow.getStartNodeId(); result = synthesizeCaseStruct(context, newFlow, fromAction, startNodeId); if (null == result) {
@Override public void inspectFlow(FacesContext context, Flow flow) Map<String, Set<NavigationCase>> rules = flow.getNavigationCases(); int rulesSize = rules.size(); flow.getId(), new _FlowNavigationStructure(flow.getDefiningDocumentId(), flow.getId(), cases, wildcardPatterns) );
private void assignInboundParameters(FacesContext context, Flow calledFlow, Map<String, Object> evaluatedParams) { // Now the new flow is active, it's time to evaluate the inbound // parameters. if (null != evaluatedParams) { Map<String, Parameter> inboundParameters = calledFlow.getInboundParameters(); ELContext elContext = context.getELContext(); String curName; ValueExpression toSet; for (Map.Entry<String, Object> curOutbound : evaluatedParams.entrySet()) { curName = curOutbound.getKey(); assert(inboundParameters.containsKey(curName)); toSet = inboundParameters.get(curName).getValue(); toSet.setValue(elContext, curOutbound.getValue()); } } }
private void doAfterEnterFlow(FacesContext context, Flow flow, Map<String, Object> outboundParameters) { getFacesFlowProvider(context).doAfterEnterFlow(context, flow); if (outboundParameters != null) { for (Map.Entry<String, Parameter> entry : flow.getInboundParameters().entrySet()) { Parameter parameter = entry.getValue(); if (parameter.getValue() != null && outboundParameters.containsKey(entry.getKey())) { parameter.getValue().setValue(context.getELContext(), outboundParameters.get(entry.getKey())); } } } if (flow.getInitializer() != null) { flow.getInitializer().invoke(context.getELContext(), null); } }
private void doBeforeExitFlow(FacesContext context, Flow flow) { if (flow.getFinalizer() != null) { flow.getFinalizer().invoke(context.getELContext(), null); } getFacesFlowProvider(context).doBeforeExitFlow(context, flow); }
@Override public void clientWindowTransition(FacesContext context) { Map<String, String> requestParamMap = context.getExternalContext().getRequestParameterMap(); String toFlowDocumentId = requestParamMap.get(TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME); String flowId = requestParamMap.get(FLOW_ID_REQUEST_PARAM_NAME); if (null != toFlowDocumentId) { // don't use *this*, due to decoration FlowHandler fh = context.getApplication().getFlowHandler(); Flow sourceFlow = fh.getCurrentFlow(context); Flow targetFlow = null; FlowCallNode flowCallNode = null; // if this is not a return... if (null != flowId && !FlowHandler.NULL_FLOW.equals(toFlowDocumentId)) { targetFlow = fh.getFlow(context, toFlowDocumentId, flowId); if (null != targetFlow && null != sourceFlow) { flowCallNode = sourceFlow.getFlowCall(targetFlow); } } else { String maxReturnDepthStr = requestParamMap.get(FLOW_RETURN_DEPTH_PARAM_NAME); int maxReturnDepth = Integer.valueOf(maxReturnDepthStr).intValue(); FlowDeque<Flow> flowStack = getFlowStack(context); flowStack.setMaxReturnDepth(context, maxReturnDepth); } fh.transition(context, sourceFlow, targetFlow, flowCallNode, context.getViewRoot().getViewId()); } }
private void pushFlow(FacesContext context, Flow toPush, String lastDisplayedViewId, Map<String, Object> evaluatedParams) { FlowDeque<Flow> flowStack = getFlowStack(context); flowStack.addFirst(toPush, lastDisplayedViewId); FlowCDIContext.flowEntered(); assignInboundParameters(context, toPush, evaluatedParams); MethodExpression me = toPush.getInitializer(); if (null != me) { me.invoke(context.getELContext(), null); } forceSessionUpdateForFlowStack(context, flowStack); }
@Override public FlowCallNode getFlowCall(Flow targetFlow) { String targetFlowId = targetFlow.getId(); if (!hasBeenInitialized) { FacesContext context = FacesContext.getCurrentInstance(); this.init(context); } FlowCallNode result = _facesFlowCallsByTargetFlowId.get(targetFlowId); return result; }
if (currentFlow != null && 0 < currentFlow.getDefiningDocumentId().length()) { String definingDocumentId = currentFlow.getDefiningDocumentId(); ExternalContext extContext = context.getExternalContext(); ApplicationAssociate associate = ApplicationAssociate.getInstance(extContext);
private void initializeNavigationFromFlowNonThreadSafe(Flow toInspect) { String fullyQualifiedFlowId = toInspect.getDefiningDocumentId() + toInspect.getId(); // Is there an existing NavigationMap for this flowId if (navigationMaps.containsKey(fullyQualifiedFlowId)) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "PENDING(edburns): merge existing map"); } } else { Map<String, Set<NavigationCase>> navRules = toInspect.getNavigationCases(); Map<String, SwitchNode> switches = toInspect.getSwitches(); if (!navRules.isEmpty() || !switches.isEmpty()) { NavigationInfo info = new NavigationInfo(); if (!switches.isEmpty()) { info.switches = new ConcurrentHashMap<>(); for (Map.Entry<String, SwitchNode> cur : switches.entrySet()) { info.switches.put(cur.getKey(), cur.getValue()); } } if (!navRules.isEmpty()) { info.ruleSet = new NavigationMap(); info.ruleSet.putAll(navRules); } navigationMaps.put(fullyQualifiedFlowId, info); } } }
private CaseStruct synthesizeCaseStruct(FacesContext context, Flow flow, String fromAction, String outcome) { CaseStruct result = null; FlowNode node = flow.getNode(outcome); if (null != node) { if (node instanceof ViewNode) { result = new CaseStruct(); result.viewId = ((ViewNode) node).getVdlDocumentId(); result.navCase = new MutableNavigationCase(fromAction, fromAction, outcome, null, result.viewId, flow.getDefiningDocumentId(), null, false, false); } else if (node instanceof ReturnNode) { String viewIdToTest = "/" + flow.getId() + "/" + outcome + currentExtension; ViewHandler viewHandler = Util.getViewHandler(context); viewIdToTest = viewHandler.deriveViewId(context, viewIdToTest);
private CaseStruct findViewNodeMatch(FacesContext context, String fromAction, String outcome) { FlowHandler flowHandler = context.getApplication().getFlowHandler(); if (null == flowHandler) { return null; } CaseStruct result = null; Flow currentFlow = flowHandler.getCurrentFlow(context); if (null != currentFlow) { FlowNode node = currentFlow.getNode(outcome); if (null != node && node instanceof ViewNode) { result = synthesizeCaseStruct(context, currentFlow, fromAction, outcome); } } if (null != result) { result.currentFlow = currentFlow; result.newFlow = currentFlow; result.facesFlowCallNode = null; } return result; }