Search code examples
grailsgroovyspring-webflow

grails webflow error


i have this grails webflow

def currencyDescriptionFlow = {
    start {
        action {
            flow.messageCommand = new MessageCommand()
            flow.currencyId = params.id
            flow.languageList = Language.findAll([sort: 'codeDescription', order: 'asc'])
        }
        on('success').to('description')
    }

    description{
        action{
            flow.DescriptionMessageList = Message.findAllByKey(flow.currencyId + '_Currency')
        }
        on('add').to('addSubmit')
        on('finish').to('currencyShow')
    }

    addSubmit{
        action {
            MessageCommand cmd ->
            flow.messageCommand = cmd
            if (!flow.messageCommand.validate()){
                error()
            }
        }
        on('error').to('description')
        on('success').to('description')
    }

    saveMessage{
        action{
            def str =  flow.currencyId + '_Currency'
            messageSevice.descriptionMultiLanguage(str, params.description, params.Language)
        }
        on('error').to('description')
        on('success').to('description')
    }

    currencyShow{
        redirect(controller:'currency', action: "show", id: flow.currencyId)
    }
}

when i click the link to redirect to this page, ann error occurs

Error 500: No transition was matched on the event(s) signaled by the [1] action(s) 
that executed in this action state 'description' of flow 'message/currencyDescription';
transitions must be defined to handle action result outcomes -- possible flow 
configuration error? Note: the eventIds signaled were: 'array<String>
['success']', while the supported set of transitional criteria for this action 
state is 'array<TransitionCriteria>[add, finish]'

Servlet: grails

URI: /adm-appserver-manager/grails/message/currencyDescription.dispatch

Exception Message: No transition was matched on the event(s) signaled by the [1] 
action(s) that executed in this action state 'description' of flow 'message/currencyDescription'; 
transitions must be defined to handle action result outcomes -- possible flow
configuration error? Note: the eventIds signaled were: 'array<String>
['success']', while the supported set of transitional criteria for this action state 
is 'array<TransitionCriteria>[add, finish]' 

Caused by: No transition was matched on the event(s) signaled by the [1] action(s) 
that executed in this action state 'description' of flow 'message/currencyDescription'; 
transitions must be defined to handle action result outcomes -- possible flow 
configuration error? Note: the eventIds signaled were: 'array<String>['success']',     
while the supported set of transitional criteria for this action state is 
'array<TransitionCriteria>[add, finish]' 

Class: Unknown 

At Line: [-1] 

Code Snippet:

Note:

where language is a table in the database
MessageCommand is command object
messageService is a service
descriptionMultiLanguage method in message service for saving message


i try this way of writing code in another action and controoler and it works without any error.


by debugging this code i found the error on ( 
on('add').to('addSubmit')
on('finish').to('currencyShow')
)
when i remove these 2 lines , no problem found

Solution

  • def currencyDescriptionFlow = {
        start {
            action {
                flow.messageCommand = new MessageCommand()
                flow.currencyId = params.id
                flow.languageList = Language.findAll([sort: 'codeDescription', order: 'asc'])
                flow.DescriptionMessageList = Message.findAllByKey(flow.currencyId + '_Currency')
            }
            on('success').to('description')
        }
    
        description{
            on('add').to('addSubmit')
            on('finish').to('currencyShow')
        }
    
        addSubmit{
            action {
                MessageCommand cmd ->
                flow.messageCommand = cmd
                if (!flow.messageCommand.validate()){
                    error()
                }
                flow.message = null
            }
            on('error').to('description')
            on('success').to('saveMessage')
        }
    
        saveMessage{
            action{
                Message messageInstance = new Message(language:flow.messageCommand.language,value:flow.messageCommand.value,key:flow.currencyId + '_Currency')
                if (!messageInstance.save(flush:true)){
                    flow.message = "${message(code: 'error.adding.description')}"
                    error()
                }
                flow.DescriptionMessageList = Message.findAllByKey(flow.currencyId + '_Currency')
            }
            on('error').to('description')
            on('success').to('description')
        }
    
        currencyShow{
            redirect(controller:'currency', action: "show", id: flow.currencyId)
        }
    }