?
Solved

how to execute spring webflow 1.0 version flows from jsp

Posted on 2011-05-04
22
Medium Priority
?
1,296 Views
Last Modified: 2013-11-13
When i click proceed link it will check the id(letterPrinting) mentioned in flow-config.xml and executed the flows(execute the first flow i.e.enterPersonalDetails) in printLetter.xml.

its working fine in spring web flow 2.0;

In spring web flow 1.0 id attribute was not there in printLetter.xml then how to execute the flows in 1.0 version when i click proceed link in jsp?



index.jsp
*********
 
 <body>
    <a href="app/letterPrinting">Proceed.</a> <br>
  </body>

  flow-config.xml
  ****************

  <webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
		<webflow:flow-location path="/flows/letterPrinting/printLetter.xml" id="letterPrinting" />
	</webflow:flow-registry>


printLetter.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">



	<view-state id="enterPersonalDetails">
		<transition on="next" to="enterCustomMessage"/>
	</view-state>

	</flow>

Open in new window

0
Comment
Question by:chaitu chaitu
  • 11
  • 10
22 Comments
 
LVL 92

Expert Comment

by:objects
ID: 35695569
> In spring web flow 1.0 id attribute was not there in printLetter.xml

sorry, don't understand what you mean. Can you explain?

http://static.springsource.org/spring-webflow/docs/1.0.x/reference/flow-definition.html
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35695858
web flow 1.0 version i am using.we cannot use id attribute in version 1.0 so how to execute flows from index.jsp..

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
Throwable occurred: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 26 in XML document from ServletContext resource [/flows/letterPrinting/printLetter.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'id' is not allowed to appear in element 'flow:location'.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'id' is not allowed to appear in element 'flow:location'.

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:flow="http://www.springframework.org/schema/webflow-config"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/webflow-config
           http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd">

<bean name="/*" class="org.springframework.webflow.executor.mvc.FlowController">
        <property name="flowExecutor" ref="flowExecutor" />
        <property name="defaultFlowId" value="/flows/letterPrinting/printLetter.xml" />
    </bean>

    <!-- Launches new flow executions and resumes existing executions. -->
    <flow:executor id="flowExecutor" registry-ref="flowRegistry">
        <flow:execution-attributes>
            <flow:alwaysRedirectOnPause value="false" />
        </flow:execution-attributes>
    </flow:executor>

    <!-- Creates the registry of flow definitions for this application -->
    <flow:registry id="flowRegistry">
        <flow:location path="/flows/letterPrinting/printLetter.xml"  id="main"/>
    </flow:registry>
	</beans>

Open in new window

0
 
LVL 92

Expert Comment

by:objects
ID: 35695903
I think it uses the filename as the id, in your case it would use 'printLetter'
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35695936
now i changed hyper link action
index.jsp
*******

<a href="app/printLetter">Proceed</a>  

when i hit this

HTTP Status 404 - /app/printLetter
0
 
LVL 92

Expert Comment

by:objects
ID: 35695988
1.0 looks for the id as a parameter by default

Try adding a RequestPathFlowExecutorArgumentHandler to your controller


    <bean name="/*" class="org.springframework.webflow.executor.mvc.FlowController">
        <property name="flowExecutor" ref="flowExecutor"/>
        <property name="argumentHandler">
            <bean class="org.springframework.webflow.executor.support.RequestPathFlowExecutorArgumentHandler"/>
        </property>        
    </bean>
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35696077

still same error.

index.jsp
********
<a href="/app/printLetter">Proceed</a>

flow-config.xml
*****************
  <bean name="/*" class="org.springframework.webflow.executor.mvc.FlowController">
        <property name="flowExecutor" ref="flowExecutor" />
           <property name="argumentHandler">
            <bean class="org.springframework.webflow.executor.support.RequestPathFlowExecutorArgumentHandler"/>
        </property> 
    </bean>

    <!-- Launches new flow executions and resumes existing executions. -->
    <flow:executor id="flowExecutor" registry-ref="flowRegistry">
        <flow:execution-attributes>
            <flow:alwaysRedirectOnPause value="false" />
        </flow:execution-attributes>
    </flow:executor>

    <!-- Creates the registry of flow definitions for this application -->
    <flow:registry id="flowRegistry">
        <flow:location path="/flows/letterPrinting/printLetter.xml" />
    </flow:registry>

Open in new window

0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 35696159
Can you check your path ....

path="/WEB-INF//flows/letterPrinting/printLetter.xml"   try this ...
0
 
LVL 92

Expert Comment

by:objects
ID: 35696165
>   <bean name="/*" class="org.springframework.webflow.executor.mvc.FlowController">

try mapping it to a specific path instead of the wildcard
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35696247
in which jar this class wil be located?i need spring webflow 1.0 version combatability jars..

am getting following error now.

java.lang.ClassNotFoundException: org.springframework.context.event.SourceFilteringListener
0
 
LVL 92

Expert Comment

by:objects
ID: 35696273
what did you change?
0
 
LVL 92

Expert Comment

by:objects
ID: 35696313
>            http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

think you need to use spring 1.x
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35696516
changed to specific path  after that i am getting this exception.

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:flow="http://www.springframework.org/schema/webflow-config"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/webflow-config
           http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd">


    <bean name="/app/" class="org.springframework.webflow.executor.mvc.FlowController">
        <property name="flowExecutor" ref="flowExecutor" />
        <property name="defaultFlowId" value="/flows/letterPrinting/printLetter.xml" />
       
    </bean>
</beans>
0
 
LVL 92

Expert Comment

by:objects
ID: 35696526
> changed to specific path  after that i am getting this exception.

great, that would suggest you're getting closer.

Did you see my previous comment? You need to make sure all your jar are comparible as well.
Migrating from 2.x to 1.x isn't trivial btw, there are quite a few changes between versions.
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35703831
now i am getting this error.

SEVERE: Servlet.service() for servlet spring threw exception
org.springframework.webflow.definition.registry.NoSuchFlowDefinitionException: No such flow definition with id '/WEB-INF/flows/letterPrinting/printLetter.xml' found; the flows available are: array<String>['printLetter']

index.jsp
**********
<a href="app/printLetter">Proceed</a>  

web.xml
*********
   <servlet>
		         <servlet-name>spring</servlet-name> 
		         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
		   </servlet>
		    <servlet-mapping> 
		    <servlet-name>spring</servlet-name>
			<url-pattern>/app/*</url-pattern>
		    </servlet-mapping> 

Open in new window

0
 
LVL 92

Expert Comment

by:objects
ID: 35703856
where is printLetter.xml?
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35704140
in this path(/WEB-INF/flows/letterPrinting/printLetter.xml.
) only.same code has worked in spring 2.0 version because we have id attribute in 2.0 so spring is able to identify if i hit with app/letterPrinting.but in 1.0 version how to execute these flows i am not able to understand.



<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
            <webflow:flow-location path="/flows/letterPrinting/printLetter.xml" id="letterPrinting" />
      </webflow:flow-registry>


0
 
LVL 92

Expert Comment

by:objects
ID: 35717011
see my earlier comment regards id's
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35734923
i am facing another problem now.

am executing flow like this.when i click proceed link its going to sample.jsp.but in this jsp ${flowExecutionUrl} is not coming.where am i missing??


http://localhost:8080/&event_Id=proceed.

its framing like this..


below jars hav placed in classpath.
commons-logging-1.0.4.jar
jdom-1.0.jar
ognl-2.6.11.jar
spring-2.0.2.jar
spring-mock-1.1.3.jar
spring-webflow-1.0.5.jar


index.jsp
***********

<a href="app?_flowId=sample-flow">Proceed</a>  

sample.jsp
*************


<%@ page isELIgnored="false" %>

<html>
<head>
<title>Insert title here</title>
</head>
<body>
<form id="frm">
<a href='${flowExecutionUrl}&_eventId=proceed'>Proceed-sample</a>
</form>
</body>
</html>

web.xml
********
   <servlet>
		         <servlet-name>spring</servlet-name> 
		         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
		   </servlet>
		    <servlet-mapping> 
		    <servlet-name>spring</servlet-name>
			<url-pattern>/app/*</url-pattern>
		    </servlet-mapping> 

webflow-confi.xml
******************
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:flow="http://www.springframework.org/schema/webflow-config"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/webflow-config
           http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd">


    <bean name="/*" class="org.springframework.webflow.executor.mvc.FlowController">
        <property name="flowExecutor" ref="flowExecutor" />
     </bean>

    <!-- Launches new flow executions and resumes existing executions. -->
    <flow:executor id="flowExecutor" registry-ref="flowRegistry">
        <flow:execution-attributes>
            <flow:alwaysRedirectOnPause value="false" />
        </flow:execution-attributes>
    </flow:executor>

    <!-- Creates the registry of flow definitions for this application -->
    <flow:registry id="flowRegistry">
        <flow:location path="/WEB-INF/**-flow.xml" />
    </flow:registry>

	<bean id="saveAction" class="com.actions.SaveAction">
    </bean>

</beans>

sample-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-1.0.xsd">


    <start-state idref="example" />
    
    <view-state id="example" view="sample">
		<transition on="proceed" to="save"/>
	</view-state>
	
	 <action-state id="save"> 
        <action bean="saveAction" method="generateCode" />
        <transition on="success" to="thanku" /> 
        </action-state>
        
        
        <view-state id="thanku" view='thanku'/> 

</flow>

Open in new window

0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 35735207
i think flowExecutionUrl is a 2.0 var
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35735230
so in 1.0 instead of flowExecutionUrl what should i use??
0
 
LVL 92

Expert Comment

by:objects
ID: 35736190
don't know you may have to construct the url manually
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 35744484
i found out the solution.

you should use _flowExecutionKey=${flowExecutionKey} in spring 1.x
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Simple Linear Regression
Progress
Suggested Courses
Course of the Month16 days, 8 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question