PDA

View Full Version : I have problem calling an embedded subflow



AndreaNobili
Oct 18th, 2011, 11:38 AM
Hello,
I am very new in Spring Web Flow. I have some problem calling an embedded subflow

The situation is this one:

I have the following directory that manage a specific HTTP Request through a flow: /WEB-INF/flows/secured/sReparti/sRepartiSegreteria

In this folder I have the following files: flow.xml (that describe the main flow), view.xhtml (that is the view showed by flow).
In this folder I have also a directory named embedded-flow that contains the definition of the sub flow

1) flow.xml is this one: there is a view-state which refers to view.xhtml view that can perform a transition to the subflow-state on the "start" event



<?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"
parent="parent-flow">

<!--
Also see ../parent-flow.xml.
-->

<view-state id="view">
<transition on="start" to="embedded-flow"/>
</view-state>

<subflow-state id="embedded-flow" subflow="secured/SReparti/sRepartiSegreteria/embedded-flow">
<input name="mode" value="'embedded'"/>

</subflow-state>

</flow>


This is my view.xhtml file that simply show 2 command button in the contentCenter area, and one of this command button send the "start" action which should start the embedded subflow:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
template="/WEB-INF/flows/secured/sReparti/view_template.xhtml">

<ui:define name="contentTop">
<p>TOP</p>
</ui:define>

<ui:define name="contentBottom">
<p>BOTTOM</p>
</ui:define>

<ui:define name="contentLeft">
<p>LEFT</p>
</ui:define>

<ui:define name="contentRight">
<p>RIGHT</p>
</ui:define>

<ui:define name="contentCenter">
<div>
<h3>Embedded Sub-Flow Area</h3>
<h:form id="mainForm">
<p:messages/>
<p>
<p:commandButton value="Start Sub-Flow" action="start" update="mainForm"/>&nbsp;
<p:commandButton value="Exit" action="exit" immediate="true" />
</p>
</h:form>
</div>
</ui:define>

</ui:composition>


Now all the information about the sub flow are in the nested directory: /WEB-INF/flows/secured/sReparti/sRepartiSegreteria/embedded-flow

In this directory infact I have: the flow.xml files (that describe the subflow behavior) and the main.xhtml files that describe the only view showed by this subflow:

This is the flow.xml subflow file: define only a view-state element associate to the main.xhtml view


<?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.xsd"
parent="parent-flow">

<!--
Also see ../parent-flow.xml.
-->

<view-state id="main" />

</flow>


And this is the main.xhtml file that describe the only view that show a different content for the contentCenter area of my layout:



<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
template="/WEB-INF/flows/secured/sReparti/view_template.xhtml">

<ui:define name="contentCenter">
<p>Sono entrato nel SubFlow</p>
</ui:define>

</ui:composition>


The problem is that I can enter in the primary flow and is displayed the view.xhtml view with its 2 command button but when I click on the "Start Sub-Flow" command button (that launches the action start) the system freezes and in the Eclipse stack trace I have the following error:



18-ott-2011 18.29.27 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [Spring MVC Servlet] in context with path [/fids] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.FlowExecutio nException: Exception thrown in state 'embedded-flow' of flow 'secured/sReparti/sRepartiSegreteria'] with root cause
org.springframework.webflow.definition.registry.No SuchFlowDefinitionException: No flow definition 'sRepartiSegreteria/embedded-flow' found
at org.springframework.webflow.definition.registry.Fl owDefinitionRegistryImpl.getFlowDefinitionHolder(F lowDefinitionRegistryImpl.java:126)
at org.springframework.webflow.definition.registry.Fl owDefinitionRegistryImpl.getFlowDefinition(FlowDef initionRegistryImpl.java:61)
at org.springframework.webflow.engine.builder.model.S ubflowExpression.getValue(SubflowExpression.java:3 5)
at org.springframework.webflow.engine.SubflowState.do Enter(SubflowState.java:97)


It seems as if he could not find the embedded Directoy flow where I defined the sub-flow...can you help me?

Thanks
Andrea
[/code]

AndreaNobili
Oct 19th, 2011, 07:50 AM
I partially solved the problem as follows:

If I put the subflow directory named "embedded-flow" directly into the "secured" directory (at the same level as all other directories containing the other flows) and if in the primary flow.xml file I put:



<subflow-state id="embedded-flow" subflow="secured/embedded-flow">
<input name="mode" value="'embedded'"/>
</subflow-state>


It's work well and the subflow is properly called when I click on the "Start" button in the first view managed by the flow...ok...

But if I try to create the "embedded-flow" directory into an other specific directory in the "/secured/" directory give me the previus error:

For example if I create "embedded-flow" directory not directly in the "secured" directory but in one of its subdirectory like: /WEB-INF/flows/secured/sReparti/sRepartiSegreteria/embedded-flow/ (and put in this ebedded-flow directory the flow.xml and main.xhtml files)

And in flow.xml of primary flow I put the right path as follow:


<subflow-state id="embedded-flow" subflow="secured/sReparti/sRepartiSegreteria/embedded-flow/>
<input name="mode" value="'embedded'"/>
</subflow-state>


Give me the error and throw the NoSuchFlowDefinitionException


With these new information can you help me to understand what is wrong?

Thanks
Andrea