The following statements are do not do what you expect it to do:
if(flow.snapshot.orderInSeries == 1) return addSnapshot()
return error()
the "event methods" (ie. error(), addSnapshot()) return null. Thus,
when you do a "return error()", it actually returns null for the model
and grails doesn't interpret the event you set.
As a workaround, you should separate the one statement into two:
error()
return
AND
if(flow.snapshot.orderInSeries == 1) {addSnapshot(); return;}
I hope that solves your problem.
-Chris
On Jul 17, 2008, at 9:16 AM, Callaway, Pamela wrote:
> Hi, thanks for the response. I saw that syntax, but I need to do
> codes other than "success" "back" or "error", and I can't seem to
> get it to work. Can we just create custom events on the fly? Or
> are "success" "back" and "error' the only triggers we can use? Or
> is there a problem with my sntax?
>
> For instance:
> def snapshotEntryFlow = {
> startEntry(){
> action {
> //do some setup stuff
> ...
> }
> on("success").to "createSnapshot"
> on(Exception).to "handleError"
> }
> createSnapshot(){
> on("finished") {
> //save snapshot and move on to next
> action
> if(!saveSeriesSnapshot(flow, params, true)) {
> flash.message += "$
> {flow.series.errors}, ${flow.snapshot.errors}"
> return error()
> }
> //Here is the test, I need to do
> createSnapshot twice (create 2 snapshots)
> //before I move on to addTransactions, if
> there is only 1 snapshot.
> //Otherwise I can continue. And alternate
> between the two.
> if(flow.snapshot.orderInSeries == 1) return
> addSnapshot()
> }.to 'addTransactions'
> on("addSnapshot").to "createSnapshot"
> }
> ...
> }
>
> This syntax doesn't seem to work at all...
>
> Thanks for any help.
>
> Pam
>
>> -----Original Message-----
>> From: Daniel Honig [mailto:
daniel.honig@...]
>> Sent: Thursday, July 17, 2008 2:30 AM
>> To:
user@...
>> Subject: Re: [grails-user] webflow transitions (just added subject to
>> last email, sorry!)
>>
>> You should be raising events and then having your handlers such as
>> ]on("foo").to("baz")
>>
>>
>> activity.validate();
>> if (activity.hasErrors()) {
>> returns errors()
>> }
>>
>> flow.activity = activity
>> return success()
>> } else {
>> flow.activityCommand = activityCommand
>> return error()
>> }
>> }
>> on("success").to "showBookingType"
>> on("back").to "showGeneralInformation"
>> on("error").to "showGeneralInformation"
>> }
>>
>>
>> On Wed, Jul 16, 2008 at 5:11 PM, Callaway, Pamela <
pcallaway@...>
>> wrote:
>>> Hi folks,
>>>
>>>
>>>
>>> I have another webflow question. I have a flow that is kind of
>> circular,
>>> meaning that I have to go back and forth between a couple of states
>> until
>>> the users are done. However, I can't seem to go from one state to
>> another
>>> inside of a state handler.
>>>
>>>
>>>
>>> The documentation seems to suggest you can just call the function of
>> the
>>> state, but that doesn't seem to work... do I need a return in
>>> front of
>> it or
>>> something?
>>>
>>>
>>>
>>> IE :
>>>
>>>
>>>
>>> Def myFlow = {
>>>
>>> doThing1 = {
>>>
>>> action {
>>>
>>> TheObject o = new TheObject()
>>>
>>> AnotherObject ao = new
>> AnotherObject()
>>>
>>> Return ['theObject':o,
>> 'otherObject':ao]
>>> //goes to the first gsp....
>>>
>>> }
>>>
>>> }
>>>
>>> doThing2 = {
>>>
>>> on("continue"){
>>>
>>> o.properties = params
>>>
>>> if(!o.save(flush:true))return
>> error()
>>>
>>> }.to "doThing3"
>>>
>>> }
>>>
>>> doThing3 = {
>>>
>>> on('continue'){
>>>
>>> //save other stuff
>>>
>>> Ao.properties = params
>>>
>>> Ao.save()
>>>
>>> If(o.someproperty == "something
>>> specific') doThing2()
>>>
>>> }.to "summary"
>>>
>>> }
>>>
>>> summary = {
>>>
>>> //just show the summary page
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> So the 'If(o.someproperty == "something specific') doThing2()' is
>> where I'm
>>> trying to jump back to the "doThing2" state, but all it does is go
>>> to
>> the
>>> summary....
>>>
>>>
>>>
>>> Any suggestions?
>>>
>>>
>>>
>>> Thanks,
>>>
>>>
>>>
>>> Pam
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>
http://xircles.codehaus.org/manage_email>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>
http://xircles.codehaus.org/manage_email>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email