|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
webflow transitions (just added subject to last email, sorry!)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 |
|
|
Re: 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 |
|
|
Re: webflow transitions (just added subject to last email, sorry!)That's exactly what stands in the ref-doc on webflow:
http://grails.org/doc/1.0.x/ref/Plug-ins/web%20flow.html |
|
|
RE: webflow transitions (just added subject to last email, sorry!)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 |
|
|
Re: webflow transitions (just added subject to last email, sorry!)Your syntax seems to suggest that you might not understand events.
put this in one of your flows inside the action block doSomething() of course it won't work but it might help you comprehend events and where you seem to be struggling. I can send samples to you privately if you really need. We have some very complicated webflows flowin' On Thu, Jul 17, 2008 at 12:16 PM, Callaway, Pamela <pcallaway@...> 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 |
|
|
Re: webflow transitions (just added subject to last email, sorry!)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 |
|
|
RE: webflow transitions (just added subject to last email, sorry!)> -----Original Message----- > From: Daniel Honig [mailto:daniel.honig@...] > Your syntax seems to suggest that you might not understand events. > > put this in one of your flows inside the action block > doSomething() > > of course it won't work > but it might help you comprehend events and where you seem to be > struggling. > I can send samples to you privately if you really need. We have some > very complicated webflows flowin' > Hi Daniel, I would LOVE to see some samples. I have read all the documentation, but it is really not enough to explain the more complicated flows. Samples are the most useful for learning, and I have found NONE (with grails syntax) anywhere that show anything other than return error(), or the simplest of situations. It would be very, very helpful to me to see some more samples! Thanks, Pam --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
RE: webflow transitions (just added subject to last email, sorry!)Hi folks,
I'd like to say thanks to Daniel who sent me a sample to look at and answered some questions. Very helpful. It appears that (correct me if I'm wrong!) when you need to call some custom event for branching or causing the webflow to transition states, that this must be done inside of an "action" block, and not anywhere else in your webflow, like inside the handler for another event. I think the "action" part was what I was missing. This is a simplified version of how I got it to work: def snapshotEntryFlow = { startEntry(){ action { //setup stuff - create the series and the snapshot } 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() } }.to 'afterCreate' } afterCreate(){ action { if(flow.snapshot.orderInSeries < 2){ //have to have 2 snapshots before transactions can be entered return addSnapshot() //addSnapshot(); //return; //putting the return after the addSnapshot did not work } //otherwise will do default action... addTransactions } on("addSnapshot").to "startEntry" on("success").to "addTransactions" } addTransactions(){ on("finished"){ if(!saveTransactions(flow, params, true)) { flash.message += "${flow.series.errors}, ${flow.snapshot.errors}" return error() } }.to "showSummary" } showSummary(){ on("addSnap"){}.to "startEntry" on("editSnap"){}.to "startEntry" } handleError(){ action { println "In handleError. params: ${params}, flow: ${flow}" println "Error: ${flow.error}" } } } > > -----Original Message----- > > From: Daniel Honig [mailto:daniel.honig@...] > > Your syntax seems to suggest that you might not understand events. > > > > put this in one of your flows inside the action block > > doSomething() > > > > of course it won't work > > but it might help you comprehend events and where you seem to be > > struggling. > > I can send samples to you privately if you really need. We have some > > very complicated webflows flowin' > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free Forum Powered by Nabble | Forum Help |