How do I pass model data beween a view state and action state in Spring Web Flow 2
In the Web Flow below I bind form data to a flow variable (lifeCycleForm) on a submit event in the view state. I have verified that the name, label and description properties are all populated as expected.
However, when the expression in the action state is evaluated all three properties are null. My form bean is serializable and I am just using simple string properties.
What I am doing wrong?
I am pretty new to Spring WebFlow so I might have missed something obvious.
<var name="lifeCycleForm" class="com.btmatthews.freelancer.lifecycle.portlet.LifeCycleForm" /> <view-state id="createLifeCycle" model="lifeCycleForm"> <binder> <binding property="name" required="true" /> <binding property="label" required="true" /> <binding property="description" required="false" /> </binder> <transition on="submit" to="createLifeCycleAction" /> <transition on="cancel" to="lifeCycleCreationCancelled" bind="false" /> </view-state> <action-state id="createLifeCycleAction"> <evaluate expression="lifeCycleService.createLifeCycle(lifeCycleForm.name, lifeCycleForm.label, lifeCycleForm.description, null, null)" /> <transition on="success" to="lifeCycleCreated" /> <transition on="failure" to="createLifeCycle" /> </action-state> <end-state id="lifeCycleCreated" /> <end-state id="lifeCycleCreationCancelled" />
Update: I neglected to mention in my original posting that it was my unit tests that were failing. I have since learned that AbstractFlowExecutionTests does not implement binding of request parameters. This seems like a bit of an oversight to me. I have tried latest nightly Spring WebFlow 2.0.4 and the behaviour remains the same.
Update: My problems are that Spring WebFlow mocks do not simulate form submission.
Thanks in advance, Brian
Asked by: Catherine163 | Posted: 21-01-2022
To much chagrin, I also recently found out that the Webflow testing mocks don't use Spring's binding. Have you tried running the flow using debugging in a container like Tomcat from within an IDE like Eclipse ? If you haven't, it'll be very useful. If you need help, I can provide further tips, but to start I'd say download the Eclipse Web Standard Tools and Web Tools Project plugins if you haven't already.
Just as a side note, if you really want to be able to unit test binding, you can also still use the Spring Webflow 1 FormActions to bind to the model object, even though it will make your flow slightly more verbose.Answered by: Edgar999 | Posted: 22-02-2022
java - The Spring AOP Proxy that isn't
I have two Spring proxies set up: <bean id="simpleBean" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target"> <ref local="simpleBeanTarget"/> </property> <property name="interceptorNames"> <list> <value>cacheInterceptor</value> </list> </property> </bean> ...
java - Basic Spring help
I'm trying out my first Spring project and must be doing something really stupid because I can't figure out how to get the following simple snippet of code to work: Here is my definition file: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springfr...
java - Spring MVC web app i18n
In a web application written using spring-MVC, I want to allow users to change the current language by clicking on a link which text is the name of the language. I have already set up a messageSource and made all my jsp pages find the messages using this messageSource. Currently, the language is changing depending on the locale of the user browser. So, what I want to do now is to allow to change the local...
java - BOF at Spring One
What is BOF ? I can see lots of mentions of it but can not find a 'relevant' definition. Bill
java - spring MVC sample web app
I'm looking for an example Spring MVC 2.5 web app that I can easily: Setup as a project in Eclipse Deploy to a local app server (using Ant/Maven) There are a couple of example applications included with the Spring distribution ('petclinic' and 'jpetstore'), but they don't provide any Eclipse project files (or a way to generate them). They also seem a bit complicated for my needs, e.g. ...
java - can any one tell me which is the best way to learn spring
Closed. This question is opinion-based. It is not c...
spring - JAR files, don't they just bloat and slow Java down?
Okay, the question might seem dumb, but I'm asking it anyways. After struggling for hours to get a Spring + BlazeDS project up and running, I discovered that I was having problems with my project as a result of not including the right dependencies for Spring etc. There were .jars missing from my WEB-INF/lib folder, yes, silly me. After a while, I managed to get all the .jar files where they belong, and it c...
java - Spring MVC form input value is always null
I'm new to Spring MVC, but not new to web development in Java. I'm attempting to create a simple form->controller example. I have a form, a form controller (configured in a context XML pasted below) and my model (a simple bean). When I submit the form the value of my text input is always null, regardless. Any ideas? Form controller spring configuration: <?xml version="1.0" encoding="UTF-...
java - Should I learn Spring 2 or 3?
Spring Framework 3 seems to be right around the corner, but the GA version is 2.5.6. If this is the first time I'm approaching the subject, should I start with the stable version, or should I start with the new version and save myself migration issues? How different is version 3 from version 2? How near is Spring 3?
Still can't find your answer? Check out these amazing Java communities for help...
Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)