如何使用flowHandler使用jsf流

如何使用flowHandler使用jsf流,jsf,jsf-2.2,faces-flow,Jsf,Jsf 2.2,Faces Flow,您好,我将使用以下方法在backingbean中完成流程步骤: transition(FacesContext context, Flow sourceFlow, Flow targetFlow, FlowCallNode outboundCallNode, String toViewId); 的 或者其他方式 例如: public void startFlow(){ // in this example we dont use jsf tags // (<h:com

您好,我将使用以下方法在backingbean中完成流程步骤:

transition(FacesContext context, Flow sourceFlow, Flow targetFlow, FlowCallNode outboundCallNode, String toViewId);

或者其他方式

例如:

public void startFlow(){

    // in this example we dont use jsf tags 
    // (<h:commandButton /> and <h:commandLink />) to navigate user through flow steps

    FlowHandler handler = context.getApplication().getFlowHandler();
    Flow targetFlow = handler.getFlow(context, "", "registerFlow");
    boolean isAdmin = checkIfAdmin();

    if(isAdmin){
      // here we forward user to viewNode of flow that name step1
      handler.transition(context, null, targetFlow, null, "step1");
    }
    else{
      // here we forward user to viewNode of flow that name step1ForAdmin
      handler.transition(context, null, targetFlow, null, "step1ForAdmin");
    }

}

在backingbean中有可能做到这一点吗?或者meaby是另一种方法?

FlowHandler是一个抽象类,用于JSF框架的内部使用。如果您想导航到JSF流的一个或另一个入口节点,只需返回目标节点的名称即可进行导航,只允许使用HTTP POST。或者,您可以通过方法调用节点或交换机节点进入流程,并在那里实现所需的导航条件

您可以阅读文章并从GitHub下载示例项目。它将向您介绍一些与JSF流相关的技术

public void startFlow(){

    // in this example we dont use jsf tags 
    // (<h:commandButton /> and <h:commandLink />) to navigate user through flow steps

    FlowHandler handler = context.getApplication().getFlowHandler();
    Flow targetFlow = handler.getFlow(context, "", "registerFlow");
    boolean isAdmin = checkIfAdmin();

    if(isAdmin){
      // here we forward user to viewNode of flow that name step1
      handler.transition(context, null, targetFlow, null, "step1");
    }
    else{
      // here we forward user to viewNode of flow that name step1ForAdmin
      handler.transition(context, null, targetFlow, null, "step1ForAdmin");
    }

}