diff --git a/.gitignore b/.gitignore index 1f68605..06e6a6a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,9 @@ plugin.xml target unzipped .settings/ -*.log \ No newline at end of file +*.log +/*.iml +/*.ipr +/*.iws +/out +/web-app \ No newline at end of file diff --git a/src/groovy/org/codehaus/groovy/grails/webflow/engine/builder/ClosureInvokingAction.groovy b/src/groovy/org/codehaus/groovy/grails/webflow/engine/builder/ClosureInvokingAction.groovy index 10f8623..47c5a1a 100644 --- a/src/groovy/org/codehaus/groovy/grails/webflow/engine/builder/ClosureInvokingAction.groovy +++ b/src/groovy/org/codehaus/groovy/grails/webflow/engine/builder/ClosureInvokingAction.groovy @@ -17,7 +17,7 @@ package org.codehaus.groovy.grails.webflow.engine.builder import grails.util.GrailsNameUtils import org.codehaus.groovy.grails.commons.GrailsDomainConfigurationUtil -import org.codehaus.groovy.grails.web.binding.GrailsDataBinder +import org.codehaus.groovy.grails.web.binding.DataBindingUtils import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -106,8 +106,7 @@ class ClosureInvokingAction extends AbstractAction { def params = noOfParams > 1 ? actionDelegate.params[GrailsNameUtils.getPropertyName(instance.class)] : actionDelegate.params if (params) { - def binder = GrailsDataBinder.createBinder(instance, instance.class.name, actionDelegate.request) - binder.bind(params) + DataBindingUtils.bindObjectToInstance(instance, params) } instance.validate() commandInstances << instance diff --git a/test/unit/org/codehaus/groovy/grails/webflow/FlowCommandObjectsTests.groovy b/test/unit/org/codehaus/groovy/grails/webflow/FlowCommandObjectsTests.groovy index 8cb3bbe..140349c 100644 --- a/test/unit/org/codehaus/groovy/grails/webflow/FlowCommandObjectsTests.groovy +++ b/test/unit/org/codehaus/groovy/grails/webflow/FlowCommandObjectsTests.groovy @@ -1,9 +1,6 @@ package org.codehaus.groovy.grails.webflow import org.codehaus.groovy.grails.webflow.support.AbstractGrailsTagAwareFlowExecutionTests -import org.springframework.webflow.definition.FlowDefinition -import org.codehaus.groovy.grails.webflow.engine.builder.FlowBuilder -import org.springframework.webflow.context.servlet.ServletExternalContext /** * Tests the functionality of command objects in web flows. @@ -65,6 +62,29 @@ class FlowCommandObjectsTests extends AbstractGrailsTagAwareFlowExecutionTests { assertFlowExecutionOutcomeEquals "end" } + void testNestedCommandInFlowTransition() { + request.addParameter("one1", "yes1") + request.addParameter("one2", "yes2") + request.addParameter("nested.nested1", "YES1") + request.addParameter("nested.nested2", "YES2") + + startFlow() + assertCurrentStateEquals("two") + + signalEvent("complex") + assertCurrentStateEquals("four") + + signalEvent("go") + assertCurrentStateEquals("stopHere") + + def model = getFlowScope() + def complex = model.complex + assert complex instanceof Command1 + assert complex.nested instanceof NestedCommand + assert complex.nested.nested1 == "YES1" + assert complex.nested.nested2 == "YES2" + } + void testCommandObjectAutowiringInFlow() { startFlow() @@ -97,6 +117,7 @@ class FlowCommandObjectsTests extends AbstractGrailsTagAwareFlowExecutionTests { flow.put('stuff',[one2:c1]) }.to "stopHere" on("else").to "three" + on("complex").to "four" } three { on("go") { AutoWireCommand1 c1 -> @@ -104,6 +125,11 @@ class FlowCommandObjectsTests extends AbstractGrailsTagAwareFlowExecutionTests { }.to "stopHere" } + four { + on("go") { Command1 c1 -> + flow.put('complex', c1) + }.to "stopHere" + } stopHere { on("end").to "end" } @@ -119,6 +145,7 @@ class AutoWireCommand1 { class Command1 { String one1 String one2 + NestedCommand nested static constraints = { one2(blank:false, nullable:false) @@ -133,3 +160,13 @@ class Command2 { two2(blank:false, nullable:false) } } + + +class NestedCommand { + String nested1 + String nested2 + + static constraints = { + nested2(blank:false, nullable:false) + } +} \ No newline at end of file