如何使用Web流程多次重定向到同一个状态 例如:
on('submit'){
def destinationInstance = Destination.get(params.destination)
def destinationGroupsInstance = DestinationGroup.get(params.destinationGroups)
def h = destinationInstance.addToDestinationGroups(destinationGroupsInstance)
}.to('flowList')
我需要的是如何在目的地结束之前多次进入这种状态 THX
答案 0 :(得分:1)
嗯,你可能有类似下面的代码,这些代码未经测试,但可能会给你一个大概的想法。
def destinationFlow = {
initialize {
action {
flow.destination = Destination.get(params.id)
}
on('success').to 'destinationList'
}
destinationList {
render(view: 'destinationList')
on('addDestination') {
def destinationGroup = DestinationGroup.get(params.destinationGroupId)
flow.destination.addToDestinationGroups(destinationGroup)
}.to 'destinationList'
on('finish').to 'done'
}
done {
flow.destination.save()
redirect(...) // out of the flow
}
}
您需要destinationList
视图上的按钮来调用'addDestination'或'finish'动作。请参阅WebFlow documentation和Reference Guide。
答案 1 :(得分:1)
on('submit'){
def destinationInstance = Destination.get(params.destination)
def destinationGroupsInstance = DestinationGroup.get(params.destinationGroups)
def h = destinationInstance.addToDestinationGroups(destinationGroupsInstance)
}.to{
(condition or while loop or for loop)
if success then
return "<state name>"
else
return "flowList"
}
参考: http://livesnippets.cloudfoundry.com/docs/guide/2.%20Grails%20webflow%20plugin.html