I have a Grails WebFlow that is similar to the following example:
def myFlow = {
init {
action {
def domain = MyDomain.get(params.id)
flow.domain = domain ? domain : new MyDomain()
}
on('success').to 'first'
}
first {
on('continue') {
flow.domain.properties = params
if(!flow.domain.validate()) {
return error()
}
}.to 'second'
}
...
}
Given this example, if a validation error occurs in the transition on('continue')
in first
:
- What's the preferred way to set the model with the invalid domain object so I can use a
<g:hasErrors>...
in my view (like I would in a normal controller action)? - When I call
error()
, does it send the flow back toinit
or tofirst
? - Does
error()
take any arguments (i.e. a model) that can be used for what I'm trying to accomplish (I can't find much documentation on theerror()
method). - I'd also take suggestions on how I could improve my flow states to better-facilitate handling these validation errors.
Summary: What's the preferred way to render validation errors within a Grails Web Flow?