我在我的应用程序中使用springwebflow 2.0。
由于应用程序正在增长,我有大量的webflow。现在我需要为特定事件创建一个单独的Webflow,例如" onchange事件的下拉列表。"
对于我在申请中的所有jsps" onchange"我想要一个单独的webFlow DomainFetcher-flow.xml来运行并返回一些值。
So far my domainFetcher-flow.xml looks like
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<on-start>
<evaluate expression="domainFetcher.fetchTableDomain()" result="conversationScope.selectDataJSON"/>
</on-start>
现在我得到一个例外,即应该定义至少一个视图状态。 所以寻找解决方案......
答案 0 :(得分:1)
是的,您可以定义没有视图状态的子流。例如,您有以下父流程,它调用子流subflow-flow.xml为:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
...
<subflow-state id="subflow-flow" subflow="subflow-flow">
<transition on="endOfSubflow" to="someStateWithMessage"/>
</subflow-state>
...
</flow>
然后在子流程中,您可以执行某些操作。您可以将subflow-flow.xml定义为:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
start-state="start">
<action-state id="start">
<evaluate expression="yourAction.performSomeAction(flowRequestContext)"/>
<transition to="endOfSubflow"/>
</action-state>
...
<end-state id="endOfSubflow"/>
</flow>
在你的动作类中:
public class YourAction{
...
public void performSomeAction(RequestContext context){
//do what you want in this method.
}
...
}
希望这有帮助。