0

how can i redirect to the same state more than one time using web flow ex:

on('submit'){
    def destinationInstance = Destination.get(params.destination)
    def destinationGroupsInstance = DestinationGroup.get(params.destinationGroups)
    def h = destinationInstance.addToDestinationGroups(destinationGroupsInstance)
}.to('flowList')

what i need is how to enter to this state more than one time until destinations ends thx

4

2 回答 2

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 文档参考指南

于 2010-10-14T18:28:23.117 回答
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

于 2011-09-22T12:12:13.150 回答