Search in sources :

Example 1 with MutableNavigationCase

use of com.sun.faces.flow.builder.MutableNavigationCase in project mojarra by eclipse-ee4j.

the class NavigationHandlerImpl method synthesizeCaseStruct.

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 fromOutcome = ((ReturnNode) node).getFromOutcome(context);
            FlowHandler flowHandler = context.getApplication().getFlowHandler();
            try {
                flowHandler.pushReturnMode(context);
                result = getViewId(context, fromAction, fromOutcome, FlowHandler.NULL_FLOW);
                // 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 MutableNavigationCase(context.getViewRoot().getViewId(), fromAction, outcome, null, toViewId, FlowHandler.NULL_FLOW, null, false, false);
                        }
                    }
                } else {
                    // setDidTransition(context, true);
                    flowHandler.transition(context, flow, null, null, result.viewId);
                    setDidTransition(context, true);
                    result.newFlow = FlowImpl.SYNTHESIZED_RETURN_CASE_FLOW;
                }
            } finally {
                flowHandler.popReturnMode(context);
            }
        }
    } else {
        // See if there is an implicit match within this flow, using outcome
        // to derive a view id within this flow.
        String currentViewId = outcome;
        // If the viewIdToTest needs an extension, take one from the currentViewId.
        String currentExtension;
        int idx = currentViewId.lastIndexOf('.');
        if (idx != -1) {
            currentExtension = currentViewId.substring(idx);
        } else {
            // PENDING, don't hard code XHTML here, look it up from configuration
            currentExtension = ".xhtml";
        }
        String viewIdToTest = "/" + flow.getId() + "/" + outcome + currentExtension;
        ViewHandler viewHandler = Util.getViewHandler(context);
        viewIdToTest = viewHandler.deriveViewId(context, viewIdToTest);
        if (null != viewIdToTest) {
            result = new CaseStruct();
            result.viewId = viewIdToTest;
            result.navCase = new MutableNavigationCase(fromAction, fromAction, outcome, null, result.viewId, null, false, false);
        }
    }
    return result;
}
Also used : ReturnNode(jakarta.faces.flow.ReturnNode) ViewHandler(jakarta.faces.application.ViewHandler) ViewNode(jakarta.faces.flow.ViewNode) MutableNavigationCase(com.sun.faces.flow.builder.MutableNavigationCase) FlowHandler(jakarta.faces.flow.FlowHandler) FlowNode(jakarta.faces.flow.FlowNode) Flow(jakarta.faces.flow.Flow)

Aggregations

MutableNavigationCase (com.sun.faces.flow.builder.MutableNavigationCase)1 ViewHandler (jakarta.faces.application.ViewHandler)1 Flow (jakarta.faces.flow.Flow)1 FlowHandler (jakarta.faces.flow.FlowHandler)1 FlowNode (jakarta.faces.flow.FlowNode)1 ReturnNode (jakarta.faces.flow.ReturnNode)1 ViewNode (jakarta.faces.flow.ViewNode)1