• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Grails Webflows

 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This follows on my questions here.

I'm trying to create a webflow for creating two objects, User and UserInformation, at the same time; the latter belongsTo the former.

In UserController I have the following action and flow:



I'm confused about a few things:

1) Why does "done with my create" get printed? I would think the redirect would cause that line to never be executed.
2) Why are the print statements in the webflow not getting called? The code itself does seem to get called because when I switch from render(view:"/user/create"); to render(view:"/user/list"); in createUser I do call up the correct view in each case.
3) How do I make the two calls to save both objects at the end of the flow?
4) Is this the right way to call the flow in the first place?
5) Anything else I'm doing wrong?

--Mark
[ March 17, 2008: Message edited by: Mark Herschberg ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not terribly familiar with Spring WebFlow, but what you've done looks pretty straight forward.

1) Why does "done with my create" get printed? I would think the redirect would cause that line to never be executed.
A redirect is not the same as a return statement. Only a return statement will end a method or closure. What you've done is similar to what can be done with a filter or with @Around in AspectJ.
2) Why are the print statements in the webflow not getting called? The code itself does seem to get called because when I switch from render(view:"/user/create"); to render(view:"/user/list"); in createUser I do call up the correct view in each case.
No clue why they aren't getting called.
3) How do I make the two calls to save both objects at the end of the flow?
Create a Service class. There's a grails command line for that. You'll see the variable that comes with the Service's skeleton method which denotes the method(?) as transactional. Call save on the domain objects (NOT the Controller) within the service method. You'll need to pass the objects over as parameters to the Service method.
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic