tags:

views:

19

answers:

1

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

+1  A: 

Well, you'd probably have something like the following code, which is untested but may give you a general idea.

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
    }
}

You'll need buttons on your destinationList view that invoke the 'addDestination' or 'finish' actions. See the WebFlow documentation and Reference Guide.

Rob Hruska
on submit i need to add the destinationGroup to destination, but not once. what's i meaning that i need to redirect to this page until all destination have destinationGroup. i find a way to redirect to the same page but i have a problem that saving in database didn't happen. do you have any solution for this problem
mbayloon
That's kind of confusing. If that's the case, why is a webflow needed? Why can't you just loop over all the available Destinations, adding the group to each? I'm probably misunderstanding what you're asking. Perhaps you can describe what your Destination and DestinationGroup entities are so that we can understand your domain.
Rob Hruska