• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Grails Webflows

 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • 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 ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic