Announcement Announcement Module
Collapse
No announcement yet.
Making a Hello World Flow... what am I missing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Making a Hello World Flow... what am I missing

    Making a Hello World Flow... what am I missing... I could not find any good examples so I started to make one. can someone please tell me what I am missing to make my Hello World Flow work.

    web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    	id="WebApp_ID" version="2.5">
    	<display-name>MyFlow</display-name>
    	<welcome-file-list>
    		<welcome-file>index.html</welcome-file>
    		<welcome-file>index.htm</welcome-file>
    		<welcome-file>index.jsp</welcome-file>
    		<welcome-file>default.html</welcome-file>
    		<welcome-file>default.htm</welcome-file>
    		<welcome-file>default.jsp</welcome-file>
    	</welcome-file-list>
    	<servlet>
    		<servlet-name>spring</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>spring</servlet-name>
    		<url-pattern>*.html</url-pattern>
    	</servlet-mapping>
    </web-app>
    spring-servlet.xml
    Code:
    <?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:p="http://www.springframework.org/schema/p"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    		http://www.springframework.org/schema/context
    		http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    
    	<context:component-scan base-package="org.uftwf.controller" />
    
    	<bean id="viewResolver"
    		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="viewClass"
    			value="org.springframework.web.servlet.view.JstlView" />
    
    		<property name="prefix" value="/WEB-INF/jsp/" />
    		<property name="suffix" value=".jsp" />
    	</bean>
    </beans>
    helloworld-flow.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE flow PUBLIC "-//SPRING//DTD WEBFLOW 1.0//EN" "http://www.springframework.org/dtd/spring-webflow-1.0.dtd">
    
    <flow start-state="helloworld">
    	<view-state id="helloworld" view="helloworld">
    	</view-state>
    </flow>
    index.jsp
    Code:
    <html>
    <head>
    	<title>Spring 3.0 MVC Series</title>
    </head>
    <body>
    	<a href="hello.html">Say Hello (Spring MVC)</a><p>
    	<a href="hello.html">Say Hello (Spring-Web-Flow)</a>
    </body>
    </html>

    So what do I have to change to get my flow working

  • #2
    You are missing the webflow configuration, there is nothing configuring webflow so that won't start... I suggest a read of the reference guide.

    Comment


    • #3
      can you please give me a sample on what I have to add and where... I need to get this up and running asap

      Comment


      • #4
        That is all clearly explained in the reference guide what to configure and register. So I again suggest you to read that.

        Comment


        • #5
          Marten Deinum, Can you please help me out and give me details on what has to be done on the above example... I need to get this flowing and I am waiting for my copy of your book

          Comment


          • #6
            I'm going into repeater mode, that is clearly explained in the reference guide, I believe it is in section 2 next part is in section3 of chapter 11

            Comment


            • #7
              I am so sorry but I am so lost on this.. I did follow the reference guide and change my spring-servlet.xml to the following

              Code:
              <?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:p="http://www.springframework.org/schema/p"
              	xmlns:context="http://www.springframework.org/schema/context"
              	xsi:schemaLocation="http://www.springframework.org/schema/beans
              		http://www.springframework.org/schem...-beans-3.0.xsd
              		http://www.springframework.org/schema/context
              		http://www.springframework.org/schema/context/spring-context-3.0.xsd"
              	xmlns:flow="http://www.springframework.org/schema/webflow-config">
              
              
              	<context:component-scan base-package="org.uftwf.controller" />
              
              	<bean id="viewResolver"
              		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
              		<property name="viewClass"
              			value="org.springframework.web.servlet.view.JstlView" />
              
              		<property name="prefix" value="/WEB-INF/jsp/" />
              		<property name="suffix" value=".jsp" />
              	</bean>
              
              <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
                  <property name="flowExecutor" ref="flowExecutor" />
              </bean>
              
              <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
                  <property name="flowRegistry" ref="flowRegistry"/>
                  <property name="order" value="0"/>
              </bean>
              	
              	
              	
              	
              <!-- 
              	<bean name="/purchase.htm"
              		class="org.springframework.webflow.executor.mvc.FlowController">
              		<constructor-arg ref="flowRegistry" />
              	</bean> -->
              
              </beans>
              but I am getting a error:
              SEVERE: StandardWrapper.Throwable
              org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.webflow.mvc.servlet.FlowHandl erAdapter#0' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Cannot resolve reference to bean 'flowExecutor' while setting bean property 'flowExecutor'; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'flowExecutor' is defined
              at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:328)

              Comment


              • #8
                Update.... Spring MVC Stopped working and Web-Flow still nothing

                I been trying my best and I updated my spring-servlet.xml file but now my Spring MVC Hello World stopped working and I still dont have Spring Web-Flow Hello World working.

                If I try to access my Spring-MVC Hello World I get the following error now:
                javax.servlet.ServletException: No adapter for handler [org.uftwf.controller.HelloWorldController@3166aab6]: Does your handler implement a supported interface like Controller?

                Below is my new spring-servlet.xml file


                Spring-servlet.xml
                Code:
                <?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:p="http://www.springframework.org/schema/p"
                	xmlns:context="http://www.springframework.org/schema/context"
                	xmlns:webflow="http://www.springframework.org/schema/webflow-config"
                	xsi:schemaLocation="http://www.springframework.org/schema/beans
                		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                		http://www.springframework.org/schema/context
                		http://www.springframework.org/schema/context/spring-context-3.0.xsd
                		http://www.springframework.org/schema/webflow-config
                		http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
                
                
                	<context:component-scan base-package="org.uftwf.controller" />
                
                	<bean id="viewResolver"
                		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
                		<property name="viewClass"
                			value="org.springframework.web.servlet.view.JstlView" />
                
                		<property name="prefix" value="/WEB-INF/jsp/" />
                		<property name="suffix" value=".jsp" />
                	</bean>
                
                	<!-- Enables FlowHandler URL mapping -->
                	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
                		<property name="flowExecutor" ref="flowExecutor" />
                	</bean>
                	
                	<webflow:flow-executor id="flowExecutor" />
                	
                	<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
                    	<webflow:flow-location-pattern value="/**/*-flow.xml" />
                	</webflow:flow-registry>
                </beans>

                Comment


                • #9
                  YOu are falling in the trap everyone falls in... As soon as you configure a HandlerAdapter explicitly the DispatcherServlet stops registering the defaults. So currently you can only execute flows and not anything else. If you want to be able to execute controllers (I assume it is a class annotated with @Controller) you need to add mvc:annotation-driven to your configuration (and of course the mvc namespace).

                  Comment


                  • #10
                    Spring MVC working now, Spring Web Flow 2 stil dont

                    thanks Marten Deinum so much that got my Spring MVC Hello World example working again but the Spring Web Flow 2 Hello World example in the same project still does not work.....

                    my spring-sevlet.xml
                    HTML Code:
                    <?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:p="http://www.springframework.org/schema/p"
                    	xmlns:context="http://www.springframework.org/schema/context"
                    	xmlns:webflow="http://www.springframework.org/schema/webflow-config"
                    	xmlns:mvc="http://www.springframework.org/schema/mvc"
                    	xsi:schemaLocation="http://www.springframework.org/schema/beans
                    		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    		http://www.springframework.org/schema/context
                    		http://www.springframework.org/schema/context/spring-context-3.0.xsd
                    		http://www.springframework.org/schema/webflow-config
                    		http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
                    		http://www.springframework.org/schema/mvc
                            http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
                    
                    
                    	<context:component-scan base-package="org.uftwf.controller" />
                    
                    	<mvc:annotation-driven />	
                    		
                    	<bean id="viewResolver"
                    		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
                    		<property name="viewClass"
                    			value="org.springframework.web.servlet.view.JstlView" />
                    		<property name="prefix" value="/WEB-INF/jsp/" />
                    		<property name="suffix" value=".jsp" />
                    	</bean>
                    	<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
                    		<property name="flowExecutor" ref="flowExecutor" />
                    	</bean>
                    		<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
                    		<property name="flowExecutor" ref="flowExecutor" />
                    	</bean>
                    	<webflow:flow-executor id="flowExecutor" />
                    	<webflow:flow-registry id="flowRegistry"
                    		base-path="/WEB-INF">
                    		<webflow:flow-location-pattern value="/**/*-flow.xml" />
                    	</webflow:flow-registry>
                    </beans>

                    Comment


                    • #11
                      What does happen, what doesn't happen. If possible post project...

                      Comment


                      • #12
                        I have all the code about.. the the war file is to big to add here

                        Comment


                        • #13
                          I assume you use something as maven or gradle to build your projects?! And not that you are searching the internet for your own combination of jar files that works?!

                          Comment


                          • #14
                            hey Marten Deinum I got your book this weekend but cant get chap10 running.. can you please help up

                            Comment


                            • #15
                              still cant get my hello world flow working.. so I posted the war with the source here on dropbox https://www.dropbox.com/s/5mojqctfqk...oWorldFlow.war

                              Please let me know if you can help

                              Comment

                              Working...
                              X