how to execute spring webflow 1.0 version flows from jsp

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

LVL 20
chaitu chaituAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
i think flowExecutionUrl is a 2.0 var
0
 
objectsCommented:
> 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
 
chaitu chaituAuthor Commented:
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
objectsCommented:
I think it uses the filename as the id, in your case it would use 'printLetter'
0
 
chaitu chaituAuthor Commented:
now i changed hyper link action
index.jsp
*******

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

when i hit this

HTTP Status 404 - /app/printLetter
0
 
objectsCommented:
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
 
chaitu chaituAuthor Commented:

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
 
Sathish David Kumar NArchitectCommented:
Can you check your path ....

path="/WEB-INF//flows/letterPrinting/printLetter.xml"   try this ...
0
 
objectsCommented:
>   <bean name="/*" class="org.springframework.webflow.executor.mvc.FlowController">

try mapping it to a specific path instead of the wildcard
0
 
chaitu chaituAuthor Commented:
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
 
objectsCommented:
what did you change?
0
 
objectsCommented:
>            http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

think you need to use spring 1.x
0
 
chaitu chaituAuthor Commented:
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
 
objectsCommented:
> 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
 
chaitu chaituAuthor Commented:
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
 
objectsCommented:
where is printLetter.xml?
0
 
chaitu chaituAuthor Commented:
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
 
objectsCommented:
see my earlier comment regards id's
0
 
chaitu chaituAuthor Commented:
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
 
chaitu chaituAuthor Commented:
so in 1.0 instead of flowExecutionUrl what should i use??
0
 
objectsCommented:
don't know you may have to construct the url manually
0
 
chaitu chaituAuthor Commented:
i found out the solution.

you should use _flowExecutionKey=${flowExecutionKey} in spring 1.x
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.