不能 return 来自 Flow
Can't return from Flow
我在 JSF 中创建了一个简单的流程,但我无法在第 2 页或第 3 页退出。
我使用@FlowDefinition 来指定起始页和end/return 页。
错误信息:
Unable to find matching navigation case with from-view-id '/flowname/step3.xhtml' for action 'exit' with outcome 'exit'
我在 Ubuntu 18.04
上使用 WildFly 16
home.xhtml(类似于start.xhtml)
...
<body jsf:id="body">
<h1>Flow with JSF 2.2</h1>
<h:form prependId="false">
<p>To start the flow:</p>
<h:commandButton value="Click here!" action="flowName"/>
</h:form>
</body>
...
start.xhtml
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:c="http://xmlns.jcp.org/jsf/core">
<head jsf:id="head">
<meta charset="UTF-8"/>
<title>In Flow</title>
</head>
<body jsf:id="body">
<h1>In Flow</h1>
<h:form prependId="false">
<!-- step2.xhtml -->
<h:commandButton id="next" value="Next" action="step2"/>
<h:commandButton id="exit" value="Home" action="exit"/>
</h:form>
</body>
</html>
step2.xhtml(类似于start.xhtml)
...
<h:form prependId="false">
<h:commandButton id="back" value="Back" action="start"/>
<h:commandButton id="next" value="Finish" action="step3"/>
<h:commandButton id="exit" value="Home" action="exit"/>
</h:form>
...
step3.xhtml(类似于start.xhtml)
...
<h:form prependId="false">
<h:commandButton id="exit" value="Home" action="exit"/>
</h:form>
...
FlowName.java
public class FlowName {
public static final String NAME = "flowName";
public static final String EXIT = "exit";
private static final String START_PATH = "/flowname/start.xhtml";
private static final String EXIT_CMD = "/home";
@Produces
@FlowDefinition
public Flow defineFlow(@FlowBuilderParameter FlowBuilder flowBuilder) {
flowBuilder.id("", NAME);
//start the flow
flowBuilder.viewNode(NAME, START_PATH).markAsStartNode();
//exit from flow
flowBuilder.returnNode(EXIT).fromOutcome(EXIT_CMD);
return flowBuilder.getFlow();
}
}
我尝试在起始页退出,但成功了。
web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>Flow with JSF 2.2</display-name>
<welcome-file-list>
<welcome-file>/home.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<!-- Info: https://javaee.github.io/tutorial/jsf-configure013.html#GIQXL -->
<param-value>Development</param-value>
</context-param>
<context-param>
<!-- it is disabled default -->
<param-name>javax.faces.CLIENT_WINDOW_MODE</param-name>
<param-value>url</param-value>
</context-param>
<servlet>
<servlet-name>JSF</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- hidden resources folder for JSF -->
<context-param>
<param-name>
javax.faces.WEBAPP_RESOURCES_DIRECTORY
</param-name>
<param-value>/WEB-INF/resources</param-value>
</context-param>
<servlet-mapping>
<servlet-name>JSF</servlet-name>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>/home</url-pattern>
</servlet-mapping>
</web-app>
效果不佳,因为流页面的名称不是以流名称开头。 (配置相同)
flowName/
flowName-start.xhtml (or flowName.xhtml the default start page)
flowName-step2.xhtml
...
默认 return 页面例如:flowName-return.xhtml
默认启动或默认 return 页面不需要任何配置(xml 或注释方法)。
See more
我在 JSF 中创建了一个简单的流程,但我无法在第 2 页或第 3 页退出。 我使用@FlowDefinition 来指定起始页和end/return 页。
错误信息:
Unable to find matching navigation case with from-view-id '/flowname/step3.xhtml' for action 'exit' with outcome 'exit'
我在 Ubuntu 18.04
上使用 WildFly 16home.xhtml(类似于start.xhtml)
...
<body jsf:id="body">
<h1>Flow with JSF 2.2</h1>
<h:form prependId="false">
<p>To start the flow:</p>
<h:commandButton value="Click here!" action="flowName"/>
</h:form>
</body>
...
start.xhtml
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:c="http://xmlns.jcp.org/jsf/core">
<head jsf:id="head">
<meta charset="UTF-8"/>
<title>In Flow</title>
</head>
<body jsf:id="body">
<h1>In Flow</h1>
<h:form prependId="false">
<!-- step2.xhtml -->
<h:commandButton id="next" value="Next" action="step2"/>
<h:commandButton id="exit" value="Home" action="exit"/>
</h:form>
</body>
</html>
step2.xhtml(类似于start.xhtml)
...
<h:form prependId="false">
<h:commandButton id="back" value="Back" action="start"/>
<h:commandButton id="next" value="Finish" action="step3"/>
<h:commandButton id="exit" value="Home" action="exit"/>
</h:form>
...
step3.xhtml(类似于start.xhtml)
...
<h:form prependId="false">
<h:commandButton id="exit" value="Home" action="exit"/>
</h:form>
...
FlowName.java
public class FlowName {
public static final String NAME = "flowName";
public static final String EXIT = "exit";
private static final String START_PATH = "/flowname/start.xhtml";
private static final String EXIT_CMD = "/home";
@Produces
@FlowDefinition
public Flow defineFlow(@FlowBuilderParameter FlowBuilder flowBuilder) {
flowBuilder.id("", NAME);
//start the flow
flowBuilder.viewNode(NAME, START_PATH).markAsStartNode();
//exit from flow
flowBuilder.returnNode(EXIT).fromOutcome(EXIT_CMD);
return flowBuilder.getFlow();
}
}
我尝试在起始页退出,但成功了。
web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>Flow with JSF 2.2</display-name>
<welcome-file-list>
<welcome-file>/home.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<!-- Info: https://javaee.github.io/tutorial/jsf-configure013.html#GIQXL -->
<param-value>Development</param-value>
</context-param>
<context-param>
<!-- it is disabled default -->
<param-name>javax.faces.CLIENT_WINDOW_MODE</param-name>
<param-value>url</param-value>
</context-param>
<servlet>
<servlet-name>JSF</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- hidden resources folder for JSF -->
<context-param>
<param-name>
javax.faces.WEBAPP_RESOURCES_DIRECTORY
</param-name>
<param-value>/WEB-INF/resources</param-value>
</context-param>
<servlet-mapping>
<servlet-name>JSF</servlet-name>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>/home</url-pattern>
</servlet-mapping>
</web-app>
效果不佳,因为流页面的名称不是以流名称开头。 (配置相同)
flowName/
flowName-start.xhtml (or flowName.xhtml the default start page)
flowName-step2.xhtml
...
默认 return 页面例如:flowName-return.xhtml
默认启动或默认 return 页面不需要任何配置(xml 或注释方法)。
See more