Announcement Announcement Module
Collapse
No announcement yet.
how can i start a web flow? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how can i start a web flow?

    how can I start a flow?
    Code:
      <div dojoType="dijit.MenuBarItem" onclick="location.href='app/simulation'">
            シミュレーション
        </div>

  • #2
    anybody can guide me on?
    please

    Comment


    • #3
      almost 2 days just to search on how to start a webflow...

      can you give me any idea on how to start a webflow?


      before in SWF1, i use FormAction class...
      Last edited by eros; Feb 18th, 2010, 06:48 AM.

      Comment


      • #4
        I'm in the same seat as you and I've been trying to follow this "simple" tutorial: https://src.springframework.org/svn/...FirstFlow.html (Here's supposedly how you set it all up.)So far I've had no luck in getting it to work but maybe you'll have better luck (It looks like every Spring-related tutorial I've come across is missing some crucial part needed to actually make the project work.) Coming from Rails development I must say that Spring MVC suffers massively from the lack of information available to beginners. The concept of KISS doesn't seem to have made it at all to the world of java-based frameworks... If it weren't for the fact that I'm required to use Spring for a course I would have dropped it long time ago and done my best to forget Spring ever existed.
        Last edited by Kristofer; Feb 18th, 2010, 10:35 AM.

        Comment


        • #5
          You won't get many answers without providing more detail. For example, your webflow configuration files, the means you're using to try to start the flow, and what actually happened, including any helpful logging messages.

          Comment


          • #6
            Originally posted by InverseFalcon View Post
            You won't get many answers without providing more detail. For example, your webflow configuration files, the means you're using to try to start the flow, and what actually happened, including any helpful logging messages.
            Well how do you start/trigger a flow? It's basically this I'm asking for. In the tutorial I provided a link to above the author just creates the helloworld-flow.xml inside a directory named helloworld inside WEB-INF. He then creates start.jsp inside helloworld, restarts the server and navigates to http://localhost:8080/appname/app/helloworld and everything just works. When I at first tried doing the same nothing happened. What I want to happen in my current project is to have "/registration" trigger the registration flow. But I can't really see how to bind this to the flow...

            My flow resides inside WEB-INF/flows/registration and consists of three jsp:s (step1.jsp, step2.jsp and step3.jsp). Here's my registration-flow.xml:
            Code:
            <?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="step1">
            		<transition on="proceed" to="step2" />
            	</view-state>
            	
            	<view-state id="step2">
            		<transition on="proceed" to="step3" />
            	</view-state>
            	
            	<view-state id="step3">
            	    <transition on="confirm" to="confirmed" />
            	    <transition on="cancel" to="cancelled" />
            	</view-state>
            	
            	<end-state id="confirmed" commit="true" />
            	
            	<end-state id="cancelled" />
            
            </flow>
            ...and here's my webflow-config:
            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:webflow="http://www.springframework.org/schema/webflow-config"
            xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/webflow-config
            http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
            	
            <!-- Configures the engine that executes web flows in this application -->
            <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" />
            
            
            <webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows" flow-builder-services="flowBuilderServices">
            
            <webflow:flow-location-pattern value="/**/*-flow.xml" />
            </webflow:flow-registry>
            
            <webflow:flow-builder-services id="flowBuilderServices" development="true" />
            
            </beans>
            Nothing happens, there are no error messages. It's just that I (and maybe TS too) don't understand how to start the flow.
            Last edited by Kristofer; Feb 18th, 2010, 02:37 PM.

            Comment


            • #7
              Looks ok so far. I'm used to using JSF with SWF, so I'm not absolutely familiar with setup using just Spring MVC.

              Speaking of which, do you have a spring MVC config file, or someplace where you're defining your view resolver (or is this just a JSF thing)?

              Lastly, I'd like to see the sections of your web.xml file where you define the Spring dispatcher and its mapping.

              Comment


              • #8
                Originally posted by InverseFalcon View Post
                Looks ok so far. I'm used to using JSF with SWF, so I'm not absolutely familiar with setup using just Spring MVC.

                Speaking of which, do you have a spring MVC config file, or someplace where you're defining your view resolver (or is this just a JSF thing)?

                Lastly, I'd like to see the sections of your web.xml file where you define the Spring dispatcher and its mapping.
                Thanks for taking the time to help out! Here's my mvc-config:
                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:mvc="http://www.springframework.org/schema/mvc"
                	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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                
                	<!-- HANDLER MAPPING RULES -->
                	
                	<!-- Maps requests to @Controllers based on @RequestMapping("path") annotation values
                		 If no annotation-based path mapping is found, Spring MVC proceeds to the next HandlerMapping (order=2 below). -->
                	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
                		<property name="order" value="1" />
                	</bean>
                	
                	<!-- Maps requests to @Controllers based on controller class name convention; e.g. a request for /hotels or a /hotels sub-resource maps to HotelsController
                	     If no class mapping is found, Spring MVC sends a 404 response and logs a pageNotFound warning. -->
                	<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
                		<property name="order" value="2" />
                	</bean>
                
                	<!-- REGISTERED HANDLER TYPES -->
                
                	<!-- Enables annotated @Controllers; responsible for invoking an annotated POJO @Controller when one is mapped. -->
                	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
                
                	<!--  VIEW RESOLUTION AND RENDERING -->
                	
                	<!-- Sets up standard HandlerMapping and HanderAdapter for use with annotations.
                	     Allows customization of various MVC-related aspects like binding and validation. -->
                	<mvc:annotation-driven />
                
                	<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
                	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                		<property name="prefix" value="/WEB-INF/views/"/>
                		<property name="suffix" value=".jsp"/>
                	</bean>
                	
                	<!-- Maps requests to flows in the flowRegistry -->
                	<bean id="flowMappings" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
                		<property name="order" value="0" />
                		<property name="flowRegistry" ref="flowRegistry" />
                	</bean>
                
                	<!-- Enables Spring Web Flow as a Spring MVC request handler -->
                	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
                		<property name="flowExecutor" ref="flowExecutor" />
                	</bean>
                	
                </beans>
                ...and web-xml:
                Code:
                <?xml version="1.0" encoding="UTF-8"?>
                <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
                	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
                
                	<!-- Enables clean URLs with JSP views e.g. /welcome instead of /app/welcome -->
                	<filter>
                		<filter-name>UrlRewriteFilter</filter-name>
                		<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
                	</filter>
                
                	<filter-mapping>
                		<filter-name>UrlRewriteFilter</filter-name>
                		<url-pattern>/*</url-pattern>
                	</filter-mapping>
                		
                	<!-- Handles all requests into the application -->
                	<servlet>
                		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
                		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                		<init-param>
                			<param-name>contextConfigLocation</param-name>
                			<param-value>
                				/WEB-INF/spring/*.xml
                			</param-value>
                		</init-param>
                		<load-on-startup>1</load-on-startup>
                	</servlet>
                		
                	<!-- Maps all /app requests to the DispatcherServlet for handling -->
                	<servlet-mapping>
                		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
                		<url-pattern>/app/*</url-pattern>
                	</servlet-mapping>
                	
                </web-app>
                My regular, non-flow jsp:s resides inside WEB-INF/views. I better provide the structure of my WEB-INF as well:
                http://i49.tinypic.com/651yso.jpg

                Comment


                • #9
                  Huh. Everything looks ok. You're including /app/ in your URL to go through the dispatcher... Your flow should be picked up by the flow location pattern in your registry...

                  I can't see any obvious misconfigurations. Can you try dropping in the HelloWorld flows and views and making sure those work? It sounds like you've got HelloWorld in a separate example project. I would go back a few steps and either try modifying the example project to work with your custom flow, or tweaking your own project so it can run the HelloWorld flow. You should be able to launch the flow by going directly to its URL. After that is confirmed to work, then you can try adding the appropriate links.

                  Turning on logging would be helpful. You can also create a FlowExecutionListener (adding it to your flowExecutor) to log or print messages when certain flow events happen. That may help you determine if webflow is being invoked at all, and if so, at what point something goes wrong.

                  Comment


                  • #10
                    Originally posted by InverseFalcon View Post
                    You should be able to launch the flow by going directly to its URL.
                    I'm not sure I understand this part, what is the URL of the flow? How do I make it to be /registration e.g. ? Is it enough for the flow just to reside inside a folder named registration? Don't I have do do something more (like some sort of binding/mapping inside webflow-config.xml)? How does Spring know that /registration should trigger a flow?

                    Comment


                    • #11
                      The URL should be something like http://localhost:8080/appname/app/registration/

                      The flowHandlerAdapter should be able to deal with this and start the flow, as mentioned in the SWF ref guide. Here's another entry dealing with the flow registry that might be useful.

                      At this point, someone with experience using SWF with Spring MVC will probably be able to help you better. My SWF and Spring MVC config entries are slightly different, and may not be applicable to your app since I'm tying in with JSF.

                      Comment


                      • #12
                        Ok, thanks for trying to help out. I appreciate it.

                        /Kris

                        Incidentally , this is the message I receive when I try to navigate to myAppName/registration:

                        Code:
                        org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/RekryteringsVerktyg/app/app/registration/] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'
                        Last edited by Kristofer; Feb 18th, 2010, 04:30 PM.

                        Comment


                        • #13
                          Originally posted by InverseFalcon View Post
                          You won't get many answers without providing more detail. For example, your webflow configuration files, the means you're using to try to start the flow, and what actually happened, including any helpful logging messages.
                          Sorry Sir, I just really don't know what I need to post...

                          Comment


                          • #14
                            Originally posted by eros View Post
                            Sorry Sir, I just really don't know what I need to post...
                            Look at Kristofer's posts as a guide. It sounds like you're making a jump from SWF 1 to SWF 2.

                            It would be best to verify that you have SWF configured correctly, thus your config files (usually named webflow-config.xml and webmvc-config.xml) are a good place to start.

                            Additionally, checking your mapping for the Spring Dispatcher in your web.xml file may help to determine what URL to use to invoke your flow.

                            Likewise, knowing the name of your flow definition xml, and where it's located in your file structure, will also be helpful.

                            Lastly, knowing what technologies you're using (JSF? Spring MVC?) in addition to SWF may help out too.

                            The purpose here is just to ensure SWF is actually configured and working correctly. You should attempt to test this by entering the URL of your flow, which should kick it off and render the first view-state. Only after we can confirm the URL is working should we look at how to invoke it from any links or buttons.

                            Comment


                            • #15
                              Code:
                              <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
                              	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                              		<property name="prefix" value="/WEB-INF/views/"/>
                              		<property name="suffix" value=".jsp"/>
                              	</bean>
                              I wonder if this could be causing trouble? the jsp:s associated with the webflow are located inside the WEB-INF/flows/registration. I thought the FlowHandlerMapping took care of this but maybe this isn't the case? My idea is that Spring goes through the different handlers in an orderly fashion, matching requests agains the appropriate handler:
                              Code:
                              <!-- Maps requests to flows in the flowRegistry -->
                              	<bean id="flowMappings" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
                              		<property name="order" value="0" />
                              		<property name="flowRegistry" ref="flowRegistry" />
                              	</bean>
                              	
                              	<!-- Maps requests to @Controllers based on @RequestMapping("path") annotation values
                              		 If no annotation-based path mapping is found, Spring MVC proceeds to the next HandlerMapping (order=2 below). -->
                              	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
                              		<property name="order" value="1" />
                              	</bean>
                              	
                              	<!-- Maps requests to @Controllers based on controller class name convention; e.g. a request for /hotels or a /hotels sub-resource maps to HotelsController
                              	     If no class mapping is found, Spring MVC sends a 404 response and logs a pageNotFound warning. -->
                              	<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
                              		<property name="order" value="2" />
                              	</bean>
                              So that if a request for a flow comes in, the flowhandler takes over and handles it.

                              webflow-config.xml:
                              Code:
                              	<!-- Configures the engine that executes web flows in this application -->
                              	<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" />
                              
                              	<!-- Registers the web flows that can be executed -->	
                              	<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows" flow-builder-services="flowBuilderServices">
                              		<!-- Register all flow definitions within the /WEB-INF/flows directory ending in "-flow.xml" -->
                              		<webflow:flow-location-pattern value="/**/*-flow.xml" />
                              	</webflow:flow-registry>
                              
                              	<!-- Configures settings used to build web flow definitions; development=true enables flow definition refresh on change -->
                              	<webflow:flow-builder-services id="flowBuilderServices" development="true" />

                              Comment

                              Working...
                              X