Posts

Showing posts with the label spring

Spring Webflow: Unit testing with Parent flows

Recently I had to test a webflow that extended a parent webflow. The documentation didn't offer much in the way of help but did suggest that you use getModelResources() method to register additional flows from the AbstractXmlFlowExecutionTests class @Override protected FlowDefinitionResource[] getModelResources(FlowDefinitionResourceFactory resourceFactory) { FlowDefinitionResource[] flowDefinitionResources = new FlowDefinitionResource[1]; flowDefinitionResources[0] = resourceFactory.createFileResource("src/main/webapp/WEB-INF/flows/base-flow.xml"); return flowDefinitionResources; } Great! Or so I thought... Below is how I extended the flow to use the base parent flow. I registered the base-flow.xml in the flowRegistry like below and I assumed that the AbstractXmlFlowExecutionTests class would register the flow as id="base" ... This was the wrong assumption, after debugging I no...

Spring-Webflow Exception The expression string to parse is required and must not be empty

Today I ran into a weird exception that was only happening on IE8, IE9. java.lang.IllegalArgumentException: The expression string to parse is required and must not be empty As this was not happening on Firefox or Chrome I began to wonder what IE was posting to the server.. After some investigation I found that IE was adding the submit button value to the POST url, see below HTML Submit Button: <input type="submit" value="Next" /> The Next value gets appended to the url: http://someurl.com/webflow/viewstate?param1=mark&param2=denieffe& =Next When Spring-Webflow tries to parse this it throws the exception above. My workaround was assign a name attribute to the html which produced a correct parameter mapping HTML Submit Button: <input type="submit" value="Next" name="nextBtn" /> The Next value gets appended to the url: http://someurl.com/webflow/viewstate?param1=mark&param2=denieffe& nextBtn=Next ...

Spring Webflow - Multiple evaluate statements in Action State

When executing mutiple expression statements in an action state you might encounter this exception org.springframework.webflow.engine.NoMatchingTransitionException: No transition was matched on the event(s) signaled by the [X] action(s) that executed in this action state This exception occurs because none of the evaluate statements trigger the transition. From the docs to trigger a transition a Action method has to return one of the following values A java.lang.String value A java.lang.Boolean value A java.lang.Enum value any other type success <action-state>    <evaluate expression="bean.setName('mark')"/>    <evaluate expression="bean.setAddress('Ireland')"/>    <transition to="myView"/> </action-state> So in our case our evaluate statements are not returning any of the event ids that will trigger a transition so we need to add the attribute element that will be set when the evaluate ...

Accessing message properties in spring webflow

Spring Webflow Version: 3.0.5-RELEASE Problem: We needed to set different messages on the one screen depending on a type of object. Instead of using JSTL in the jsp file we decided to set the message in the flow xml file. To access and set a message in flowscope in webflow use the following snippet. <set name="flowScope.message" value="resourceBundle['some.view.message.header']" />