Reputation: 332
I am using springwebflow 2.0 in my application.
Since the application is growing, I am having large number of webflows. Now I need to create a separate webflow for a particular event like "onchange event of dropdowns."
For all the jsps in my application on the event of "onchange" I want a separate webFlow DomainFetcher-flow.xml to run and return some value.
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>
Right now I am getting an exception that at least one view state should be defined. So looking for a solution...
Upvotes: 1
Views: 704
Reputation: 3795
Yes you can define a subflow without a view state. For example, you have below parent flow which invokes subflow subflow-flow.xml as :
<?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>
Then in subflow you can perform some action. You can define subflow-flow.xml as:
<?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>
In your action class:
public class YourAction{
...
public void performSomeAction(RequestContext context){
//do what you want in this method.
}
...
}
Hope this helps.
Upvotes: 1