Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ plugin.xml
target
unzipped
.settings/
*.log
*.log
/*.iml
/*.ipr
/*.iws
/out
/web-app
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -97,13 +117,19 @@ class FlowCommandObjectsTests extends AbstractGrailsTagAwareFlowExecutionTests {
flow.put('stuff',[one2:c1])
}.to "stopHere"
on("else").to "three"
on("complex").to "four"
}
three {
on("go") { AutoWireCommand1 c1 ->
flow.put('cmd', c1)
}.to "stopHere"

}
four {
on("go") { Command1 c1 ->
flow.put('complex', c1)
}.to "stopHere"
}
stopHere {
on("end").to "end"
}
Expand All @@ -119,6 +145,7 @@ class AutoWireCommand1 {
class Command1 {
String one1
String one2
NestedCommand nested

static constraints = {
one2(blank:false, nullable:false)
Expand All @@ -133,3 +160,13 @@ class Command2 {
two2(blank:false, nullable:false)
}
}


class NestedCommand {
String nested1
String nested2

static constraints = {
nested2(blank:false, nullable:false)
}
}