Package javax.faces.flow

Examples of javax.faces.flow.Flow


        CaseStruct result = null;
        FlowHandler flowHandler = context.getApplication().getFlowHandler();
        if (null == flowHandler) {
            return null;
        }
        Flow currentFlow = flowHandler.getCurrentFlow(context);
        if (null != currentFlow) {
            FlowNode node = currentFlow.getNode(outcome);
            if (node instanceof MethodCallNode) {
                MethodCallNode methodCallNode = (MethodCallNode) node;
                MethodExpression me = methodCallNode.getMethodExpression();
                if (null != me) {
                    List<Parameter> paramList= methodCallNode.getParameters();
View Full Code Here


        FlowHandler flowHandler = context.getApplication().getFlowHandler();
        if (null == flowHandler) {
            return null;
        }
        Flow currentFlow = flowHandler.getCurrentFlow(context);
        Flow newFlow = null;
        FlowCallNode facesFlowCallNode = null;
        if (null != currentFlow) {
            FlowNode node = currentFlow.getNode(outcome);
            if (node instanceof FlowCallNode) {
                facesFlowCallNode = (FlowCallNode) node;
                String flowId = facesFlowCallNode.getCalledFlowId(context);
                String flowDocumentId = facesFlowCallNode.getCalledFlowDocumentId(context);

                if (null != flowId) {
                    newFlow = flowHandler.getFlow(context, flowDocumentId, flowId);
                    if (null != newFlow) {
                        String startNodeId = newFlow.getStartNodeId();
                        result = synthesizeCaseStruct(context, newFlow, fromAction, startNodeId);
                        if (null == result) {
                            assert(null != currentFlow);
                            // If no CaseStruct can be synthesized, we must execute the
                            // navigation handler algorithm to try to find the CaseStruct
                            // for the start node.  However, in order to do that, we
                            // must enter the new flow.  To preserve the intergity
                            // of the state machine, we enter the flow now, and mark
                            // that we must not enter it later.
                            try {
                                setDidTransition(context, true);
                                flowHandler.transition(context, currentFlow, newFlow, null, startNodeId);
                                result = getViewId(context, fromAction, startNodeId, toFlowDocumentId);
                            }
                            finally {
                                if (null == result) {
                                    // If we did not find a CaseStruct, preserve the
                                    // integrity of the state machine by transitioning
                                    // out of the flow.
                                    flowHandler.transition(context, newFlow, currentFlow, null, outcome);
                                    setDidTransition(context, false);
                                }
                            }
                        }
                    }
                }
            }
        } else {
            // See if we are trying to enter a flow.
            newFlow = flowHandler.getFlow(context, toFlowDocumentId, outcome);
            if (null != newFlow) {
                String startNodeId = newFlow.getStartNodeId();
                result = synthesizeCaseStruct(context, newFlow, fromAction, startNodeId);
                if (null == result) {
                    assert(null == currentFlow);
                    // If no CaseStruct can be synthesized, we must execute the
                    // navigation handler algorithm to try to find the CaseStruct
View Full Code Here

        FlowHandler flowHandler = context.getApplication().getFlowHandler();
        if (null == flowHandler) {
            return null;
        }
        Flow currentFlow = flowHandler.getCurrentFlow(context);
        if (null != currentFlow) {
            FlowNode node = currentFlow.getNode(outcome);
            if (null != node) {
                if (node instanceof ViewNode) {
                    result = synthesizeCaseStruct(context, currentFlow, fromAction, outcome);
                }
            }
View Full Code Here

        CaseStruct result = null;
        FlowHandler flowHandler = context.getApplication().getFlowHandler();
        if (null == flowHandler) {
            return null;
        }
        Flow currentFlow = flowHandler.getCurrentFlow(context);
        if (null != currentFlow) {
            // If so, see if the outcome is one of this flow's
            // faces-flow-return nodes.
            ReturnNode returnNode = currentFlow.getReturns().get(outcome);
            if (null != returnNode) {
                String fromOutcome = returnNode.getFromOutcome(context);
                try {
                    flowHandler.pushReturnMode(context);
                    result = getViewId(context, fromAction, fromOutcome, FlowHandler.NULL_FLOW);
                    // We are in a return node, but no result can be found from that
                    // node.  Show the last displayed viewId from the preceding flow.
                    if (null == result) {
                        Flow precedingFlow = flowHandler.getCurrentFlow(context);
                        if (null != precedingFlow) {
                            String toViewId = flowHandler.getLastDisplayedViewId(context);
                            if (null != toViewId) {
                                result = new CaseStruct();
                                result.viewId = toViewId;
View Full Code Here

            {
                FacesConfigurator.enableDefaultWindowMode(facesContext);
            }
            while (it.hasNext())
            {
                Flow flow = it.next();

                if (flow instanceof FlowImpl)
                {
                    ((FlowImpl)flow).freeze();
                }
View Full Code Here

    }

    @Override
    public Map<Object, Object> getCurrentFlowScope(FacesContext facesContext)
    {
        Flow flow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
        Map<Object, Object> map = null;
        if (flow != null)
        {
            String mapKey = CURRENT_FLOW_SCOPE_MAP+SEPARATOR_CHAR+
                flow.getDefiningDocumentId()+SEPARATOR_CHAR+flow.getId();
            map = (Map<Object, Object>) facesContext.getAttributes().get(mapKey);
            if (map == null)
            {
                String flowMapKey = flow.getClientWindowFlowId(
                    facesContext.getExternalContext().getClientWindow());
               
                map = new FlowScopeMap(this, flowMapKey);
                //String fullToken = FLOW_SESSION_MAP_SUBKEY_PREFIX + SEPARATOR_CHAR + flowMapKey;
                //map = createOrRestoreMap(facesContext, fullToken);
View Full Code Here

       
        // First try the combination.
        Map<String, Flow> flowMap = _flowMapByDocumentId.get(definingDocumentId);
        if (flowMap != null)
        {
            Flow flow = flowMap.get(id);
            if (flow != null)
            {
                return flow;
            }
        }
View Full Code Here

            flowMap = new ConcurrentHashMap<String, Flow>();
            _flowMapByDocumentId.put(definingDocumentId, flowMap);
        }
        flowMap.put(id, toAdd);
       
        Flow duplicateFlow = _flowMapById.get(id);
        if (duplicateFlow != null)
        {
            // There are two flows with the same flowId.
            // Give priority to the flow with no defining document id
            if ("".equals(toAdd.getDefiningDocumentId()))
            {
                _flowMapById.put(id, toAdd);
            }
            else if ("".equals(duplicateFlow.getDefiningDocumentId()))
            {
                // Already added, skip
            }
            else
            {
View Full Code Here

        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
        submit(button);
       
        processLifecycleExecute();
       
        Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
        Assert.assertNotNull(currentFlow);
       
        contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
       
        Assert.assertNotNull(contentCase);
View Full Code Here

               
                boolean failed = false;
                int i = 0;
                while (FlowHandler.NULL_FLOW.equals(toFlowDocumentId) && !failed)
                {
                    Flow currentFlow = flowHandler.getCurrentFlow(context);
                    if (currentFlow == null)
                    {
                        failed = true;
                        break;
                    }
                    String currentLastDisplayedViewId = flowHandler.getLastDisplayedViewId(context);
                    FlowNode node = currentFlow.getNode(fromOutcome);
                    if (node instanceof ReturnNode)
                    {
                        if (targetFlows == null)
                        {
                            sourceFlows = new ArrayList<Flow>(4);
                            targetFlows = new ArrayList<Flow>(4);
                        }
                        // Get the navigation case using the outcome
                        Flow sourceFlow = currentFlow;
                        flowHandler.pushReturnMode(context);
                        currentFlow = flowHandler.getCurrentFlow(context);
                        i++;
                       
                        NavigationCase navCase = nh.getNavigationCase(context, null,
                            ((ReturnNode) node).getFromOutcome(context), FlowHandler.NULL_FLOW);

                        if (navCase == null)
                        {
                            if (currentLastDisplayedViewId != null)
                            {
                                sourceFlows.add(sourceFlow);
                                if (currentFlow != null)
                                {
                                    toFlowDocumentId = currentFlow.getDefiningDocumentId();
                                    targetFlows.add(currentFlow);
                                }
                                else
                                {
                                    // No active flow
                                    toFlowDocumentId = null;
                                    targetFlows.add(null);
                                }
                            }
                            else
                            {
                                // Invalid state because no navCase and
                                // no saved lastDisplayedViewId into session
                                failed = true;
                            }
                        }
                        else
                        {
                            if (FlowHandler.NULL_FLOW.equals(navCase.getToFlowDocumentId()))
                            {
                                fromOutcome = navCase.getFromOutcome();
                            }
                            else
                            {
                                sourceFlows.add(sourceFlow);
                                // The absence of FlowHandler.NULL_FLOW means the return went somewhere else.
                                if (currentFlow != null)
                                {
                                    toFlowDocumentId = currentFlow.getDefiningDocumentId();
                                    targetFlows.add(currentFlow);
                                }
                                else
                                {
                                    // No active flow
                                    toFlowDocumentId = null;
                                    targetFlows.add(null);
                                }
                            }
                        }
                    }
                    else
                    {
                        // No return node found in current flow, push it and check
                        // the next flow
                        flowHandler.pushReturnMode(context);
                        currentFlow = flowHandler.getCurrentFlow(context);
                        i++;
                        if (currentFlow == null)
                        {
                            failed = true;
                        }
                    }
                }
                for (int j = 0; j<i; j++)
                {
                    flowHandler.popReturnMode(context);
                }
                if (failed)
                {
                    // Do nothing.
                }
                else
                {
                    //Call transitions.
                    for (int j = 0; j < targetFlows.size(); j++)
                    {
                        Flow sourceFlow = sourceFlows.get(j);
                        Flow targetFlow = targetFlows.get(j);
                        flowHandler.transition(context,
                            sourceFlow,
                            targetFlow, null, context.getViewRoot().getViewId());
                       
                    }
                }
            }
            else
            {
                // This transition is for start a new flow. In this case
                // FlowHandler.FLOW_ID_REQUEST_PARAM_NAME could be the flow name to enter
                // or the flow call node to activate.
                // 1. check if is a flow
                Flow targetFlow = flowHandler.getFlow(context, flowDocumentIdRequestParam, flowIdRequestParam);
                Flow currentFlow = null;
                FlowCallNode outboundCallNode = null;
                FlowNode node = null;
                if (targetFlow == null)
                {
                    //Check if is a call flow node
                    List<Flow> activeFlows = FlowHandlerImpl.getActiveFlows(context, flowHandler);
                    for (Flow activeFlow : activeFlows)
                    {
                        node = activeFlow != null ? activeFlow.getNode(flowIdRequestParam) : null;
                        if (node != null && node instanceof FlowCallNode)
                        {
                            outboundCallNode = (FlowCallNode) node;

                            String calledFlowDocumentId = outboundCallNode.getCalledFlowDocumentId(context);
                            if (calledFlowDocumentId == null)
                            {
                                calledFlowDocumentId = activeFlow.getDefiningDocumentId();
                            }
                            targetFlow = flowHandler.getFlow(context,
                                calledFlowDocumentId,
                                outboundCallNode.getCalledFlowId(context));
                            if (targetFlow == null && !"".equals(calledFlowDocumentId))
                            {
                                targetFlow = flowHandler.getFlow(context, "",
                                    outboundCallNode.getCalledFlowId(context));
                            }
                            if (targetFlow != null)
                            {
                                currentFlow = activeFlow;
                                break;
                            }
                        }
                    }
                }
               
                if (targetFlow != null)
                {
                    if (flowHandler.isActive(context, targetFlow.getDefiningDocumentId(), targetFlow.getId()))
                    {
                        Flow baseReturnFlow = flowHandler.getCurrentFlow();
                        if (!(baseReturnFlow.getDefiningDocumentId().equals(targetFlow.getDefiningDocumentId()) &&
                             baseReturnFlow.getId().equals(targetFlow.getId())))
                        {
                            flowHandler.transition(context,
                                baseReturnFlow, targetFlow, outboundCallNode, context.getViewRoot().getViewId());
                        }
                        flowHandler.pushReturnMode(context);
                        Flow previousFlow = flowHandler.getCurrentFlow(context);
                        flowHandler.popReturnMode(context);
                        flowHandler.transition(context,
                                targetFlow, previousFlow, outboundCallNode, context.getViewRoot().getViewId());
                    }
                    // Invoke transition
View Full Code Here

TOP

Related Classes of javax.faces.flow.Flow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.