Package javax.faces.flow

Examples of javax.faces.flow.FlowHandler


            {
                throw new IllegalStateException("Flow "+ reference.getId()+
                    " cannot be found when resolving bean " + bean.toString());
            }
           
            FlowHandler flowHandler = facesContext.getApplication().getFlowHandler();
            // Since it is possible to have only the flow id without documentId, the best
            // is first get the flow using flowHandler.getFlow and then check if the flow is
            // active or not, but using the documentId and id of the retrieved flow.
            Flow flow = flowHandler.getFlow(facesContext,
                reference.getDocumentId() == null ? "" : reference.getDocumentId(), reference.getId());
            if (flow == null)
            {
                throw new IllegalStateException(bean.toString() + "cannot be created because flow "+ reference.getId()+
                    " is not registered");
            }
            if (!flowHandler.isActive(facesContext, flow.getDefiningDocumentId(), flow.getId()))
            {
                throw new IllegalStateException(bean.toString() + "cannot be created if flow "+ reference.getId()+
                    " is not active");
            }
           
View Full Code Here


            return Collections.emptyList();
        }
        if ( Boolean.TRUE.equals(context.getAttributes().get(RETURN_MODE)) )
        {
            // Use the standard form
            FlowHandler fh = context.getApplication().getFlowHandler();
            Flow curFlow = fh.getCurrentFlow(context);
            if (curFlow != null)
            {
                List<Flow> activeFlows = new ArrayList<Flow>();
                while (curFlow != null)
                {
                    activeFlows.add(curFlow);
                    fh.pushReturnMode(context);
                    curFlow = fh.getCurrentFlow(context);
                }

                for (int i = 0; i < activeFlows.size(); i++)
                {
                    fh.popReturnMode(context);
                }
                return activeFlows;
            }
            else
            {
View Full Code Here

        return currentFlowStack;
    }
   
    public static List<Flow> getActiveFlows(FacesContext facesContext, FlowHandler fh)
    {
        FlowHandler flowHandler = fh;
        while (flowHandler != null)
        {
            if (flowHandler instanceof FlowHandlerImpl)
            {
                break;
View Full Code Here

                // If we don't have an fromOutcome, it is not possible to calculate the transitions
                // involved.
                return;
            }
           
            FlowHandler flowHandler = context.getApplication().getFlowHandler();
            ConfigurableNavigationHandler nh =
                (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
           
            if (FlowHandler.NULL_FLOW.equals(flowDocumentIdRequestParam))
            {
                // It is a return node. The trick here is we need to calculate
                // where the flow should return, because that information was not passed
                // in the parameters of the link.
                String toFlowDocumentId = FlowHandler.NULL_FLOW;
                String fromOutcome = flowIdRequestParam;
                //Flow sourceFlow = null;
                List<Flow> sourceFlows = null;
                List<Flow> targetFlows = null;
               
                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)
                {
                    //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
                    flowHandler.transition(context,
                        currentFlow, targetFlow, outboundCallNode, context.getViewRoot().getViewId());

                    // Handle 2 or more flow consecutive start.
                    boolean failed = false;
                   
                    String startNodeId = targetFlow.getStartNodeId();
                    while (startNodeId != null && !failed)
                    {
                        NavigationCase navCase = nh.getNavigationCase(context, null,
                                    startNodeId, targetFlow.getDefiningDocumentId());
                       
                        if (navCase != null && navCase.getToFlowDocumentId() != null)
                        {
                            currentFlow = flowHandler.getCurrentFlow(context);
                            node = currentFlow.getNode(navCase.getFromOutcome());
                            if (node != null && node instanceof FlowCallNode)
                            {
                                outboundCallNode = (FlowCallNode) node;
                               
                                String calledFlowDocumentId = outboundCallNode.getCalledFlowDocumentId(context);
                                if (calledFlowDocumentId == null)
                                {
                                    calledFlowDocumentId = currentFlow.getDefiningDocumentId();
                                }
                                targetFlow = flowHandler.getFlow(context,
                                    calledFlowDocumentId,
                                    outboundCallNode.getCalledFlowId(context));
                                if (targetFlow == null && !"".equals(calledFlowDocumentId))
                                {
                                    targetFlow = flowHandler.getFlow(context, "",
                                        outboundCallNode.getCalledFlowId(context));
                                }
                            }
                            else
                            {
                                String calledFlowDocumentId = navCase.getToFlowDocumentId();
                                if (calledFlowDocumentId == null)
                                {
                                    calledFlowDocumentId = currentFlow.getDefiningDocumentId();
                                }
                                targetFlow = flowHandler.getFlow(context,
                                    calledFlowDocumentId,
                                    navCase.getFromOutcome());
                                if (targetFlow == null && !"".equals(calledFlowDocumentId))
                                {
                                    targetFlow = flowHandler.getFlow(context, "",
                                        navCase.getFromOutcome());
                                }
                            }
                            if (targetFlow != null)
                            {
                                flowHandler.transition(context,
                                    currentFlow, targetFlow, outboundCallNode, context.getViewRoot().getViewId());
                                startNodeId = targetFlow.getStartNodeId();
                            }
                            else
                            {
View Full Code Here

   
   
    private CaseStruct findReturnMatch(FacesContext context,
            String fromAction, String outcome) {
        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;
                                result.navCase = new NavigationCase(context.getViewRoot().getViewId(),
                                        fromAction,
                                        outcome,
                                        null,
                                        toViewId,
                                        FlowHandler.NULL_FLOW,                           
                                        null,
                                        false,
                                        false);
                               
                            }
                        }
                    }
                }
                finally {
                    flowHandler.popReturnMode(context);
                }
            }
        }
        if (null != result) {
            result.currentFlow = currentFlow;
View Full Code Here

                if (cncHasCondition && Boolean.FALSE.equals(cnc.getCondition(ctx))) {
                    match = false;
                } else {
                    toFlowDocumentId = (null != cnc.getToFlowDocumentId()) ? cnc.getToFlowDocumentId() : toFlowDocumentId;
                    if (null != toFlowDocumentId) {
                        FlowHandler fh = ctx.getApplication().getFlowHandler();
                        result.isFlowEntryFromExplicitRule = null != fh.getFlow(ctx, toFlowDocumentId, outcome);
                    }
                    return result;
                }
            }
        }
View Full Code Here

            } else {
                UIViewRoot newRoot = viewHandler.createView(context,
                                                            caseStruct.viewId);
                updateRenderTargets(context, caseStruct.viewId);
                context.setViewRoot(newRoot);
                FlowHandler flowHandler = context.getApplication().getFlowHandler();
                if (null != flowHandler && !isDidTransition(context)) {
                    flowHandler.transition(context,
                            caseStruct.currentFlow, caseStruct.newFlow,
                            caseStruct.facesFlowCallNode, caseStruct.viewId);
                    setDidTransition(context, false);
                }
                if (logger.isLoggable(Level.FINE)) {
View Full Code Here

    }
   
    private Set<String> getWildCardMatchList(FacesContext context) {
        Set<String> result = Collections.emptySet();
        NavigationInfo info = null;
        FlowHandler fh = context.getApplication().getFlowHandler();
        if (null != fh) {
            Flow currentFlow = fh.getCurrentFlow(context);
            if (null != currentFlow) {
                info = navigationMaps.get(currentFlow.getDefiningDocumentId() + currentFlow.getId());
            }
        }
        if (null == info) {
View Full Code Here

    private NavigationInfo getNavigationInfo(FacesContext context, String toFlowDocumentId, String flowId) {
        NavigationInfo result = null;
        assert(null != navigationMaps);
        result = navigationMaps.get(toFlowDocumentId + flowId);
        if (null == result) {
            FlowHandler fh = context.getApplication().getFlowHandler();
            if (null != fh) {
                Flow currentFlow = fh.getCurrentFlow(context);
                if (null != currentFlow) {
                    result = navigationMaps.get(currentFlow.getDefiningDocumentId() + currentFlow.getId());
                }
            }
        }
View Full Code Here

        }
       
        // If we still don't have a match...
        if (caseStruct == null && outcome != null && viewId != null) {

            FlowHandler flowHandler = ctx.getApplication().getFlowHandler();
            if (null != flowHandler) {

                Flow currentFlow = null;
                Flow newFlow = null;
                currentFlow = flowHandler.getCurrentFlow(ctx);
                if (null != currentFlow) {
                    caseStruct = findRootNavigationMapAbandonedFlowMatch(ctx, viewId, fromAction, outcome, toFlowDocumentId);
                }
            }
           
View Full Code Here

TOP

Related Classes of javax.faces.flow.FlowHandler

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.