|
I'm trying to trigger a view transition using a <g:link> tag, but I can't get it to work. I know it's possible because of this statement from the ref docs:
"If you don't have a form you can also trigger an event with the <g:link> tag ..." So, I have the following setup: def buildListingFlow = { initialize { action { //setup code return one() } on("one").to("generalInfo") on("navigate"){println "Foo!"}.to("propertySummary") } generalInfo { [user: flow.user] on("next") { }.to("propertySummary") on("navigate"){println "Bazz!"}.to("propertySummary") } propertySummary { println "propertySummary called" on("back") { }.to("generalInfo") on("next") { }.to("financialSummary") } navigate { println "navigate called!" } } As you can see, I have a few printlns to try and discover if anything is being called. My html to trigger a transition looks like this: <g:link action="buildListing" event="navigate">Property Summary</g:link> I would expect the navigate action to be called, but I'm getting nothing at all. I'm hoping that I'm missing something simple. The flow works just fine using submit buttons, but using a g:link has no effect at all. Any thoughts? |
|
What does the generated <a> look like?
-- Jonathan Rosenberg Founder & Executive Director Tabby's Place, a Cat Sanctuary On Wed, Jun 29, 2011 at 6:59 PM, mjohnsonaz74 <[hidden email]> wrote: > I'm trying to trigger a view transition using a <g:link> tag, but I can't get > it to work. I know it's possible because of this statement from the ref > docs: > "If you don't have a form you can also trigger an event with the <g:link> > tag ..." > > So, I have the following setup: > > def buildListingFlow = { > initialize { > action { > //setup code > return one() > } > on("one").to("generalInfo") > on("navigate"){println "Foo!"}.to("propertySummary") > } > generalInfo { > [user: flow.user] > on("next") { > > }.to("propertySummary") > on("navigate"){println "Bazz!"}.to("propertySummary") > } > > propertySummary { > println "propertySummary called" > > on("back") { > }.to("generalInfo") > > on("next") { > }.to("financialSummary") > } > navigate { > println "navigate called!" > } > } > > As you can see, I have a few printlns to try and discover if anything is > being called. My html to trigger a transition looks like this: > <g:link action="buildListing" event="navigate">Property Summary</g:link> > > I would expect the navigate action to be called, but I'm getting nothing at > all. I'm hoping that I'm missing something simple. The flow works just > fine using submit buttons, but using a g:link has no effect at all. Any > thoughts? > > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Webflow-with-g-link-tp3634286p3634286.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > 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 |
|
In reply to this post by mjohnsonaz74
Your flow doesn't seem to be correct. You should be aware of the difference between flow definition code and flow execution code (see inline comments).
Grtz, Ivo On 30 Jun 2011, at 00:59, mjohnsonaz74 wrote: > I'm trying to trigger a view transition using a <g:link> tag, but I can't get > it to work. I know it's possible because of this statement from the ref > docs: > "If you don't have a form you can also trigger an event with the <g:link> > tag ..." > > So, I have the following setup: > > def buildListingFlow = { > initialize { > action { > //setup code > return one() > } > on("one").to("generalInfo") > on("navigate"){println "Foo!"}.to("propertySummary") -> this transition will never be triggered > } > generalInfo { > [user: flow.user] -> this code will only once be executed at flow definition time, you probably need an 'onEntry' block > on("next") { > > }.to("propertySummary") > on("navigate"){println "Bazz!"}.to("propertySummary") > } > > propertySummary { > println "propertySummary called" -> this code will only once be executed at flow definition time, you probably need an 'onEntry' block > > on("back") { > }.to("generalInfo") > > on("next") { > }.to("financialSummary") > } > navigate { > println "navigate called!" -> this is an end state and may only contain a redirect and/or output statement > } > } --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Okay, good information about the onEntry. I didn't see that in the webflow docs. Now, I have this code:
<g:link action="buildListing" event="navigate">Property Summary</g:link> which translates to: <a href="/reliquid/offering/buildListing?execution=e1s3&_eventId=navigate">Property Summary</a> My flow def looks like this(abbreviated): def buildListingFlow = { initialize { action { ...snip //setup code return one() } on("one").to("generalInfo") } generalInfo { onEntry { println "entered general info" } on("next") { println params ..snip }.to("propertySummary") } propertySummary { onEntry { println "entered property summary" } on("back") { }.to("generalInfo") } navigate { onEntry { println "entered" } } end { //included for end state } } All I'm trying to accomplish right now is for me to click on a link, like the one above, and trigger a transition. The use case is that each link is a node in a menu tree. When I click on a node, I want to be taken to that specific flow state/view. I would think that clicking on the link would cause the 'navigate' block to execute. However, I'm not getting the println so that's not what's happening. I'm going to go back and research some more about the flow def vs the flow execution. Thank you very much so far, your onEntry suggestion was a good illustration that not all information is in the ref docs. Does anything else in my setup look incorrect to you? |
|
Not sure which view state that link is being generated from but if it is generalInfo. The generalInfo view state needs a on("navigate").to("navigate")
Ben |
|
The link is generated on all views, but in this use case it would be from the generalInfo view. Adding the 'on' for navigate to the generalInfo block doesn't work either.
def buildListingFlow = { initialize { action { ...snip //setup code return one() } on("one").to("generalInfo") } generalInfo { onEntry { println "entered general info" } on("next") { println params ..snip }.to("propertySummary") on("navigate") { println "Bazz!" }.to("propertySummary") //PropertySummary is where I want to go, the navigate block is to try and determine what's going where. } propertySummary { onEntry { println "entered property summary" } on("back") { }.to("generalInfo") } navigate { onEntry { println "entered" } } end { //included for end state } } |
|
Does anyone have a flow definition that uses a g:link that they could post so I can at least make sure I'm defining my links correctly? I'm sure I'm doing something wrong and that, whatever it is, it's probably a small omission on my part.
--MJ |
|
See http://livesnippets.cloudfoundry.com
Grtz, Ivo On 01 Jul 2011, at 21:20, mjohnsonaz74 wrote: > Does anyone have a flow definition that uses a g:link that they could post so > I can at least make sure I'm defining my links correctly? I'm sure I'm > doing something wrong and that, whatever it is, it's probably a small > omission on my part. > > --MJ > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Webflow-with-g-link-tp3634286p3639096.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > 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 |
| Powered by Nabble | Edit this page |
