This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Grails Webflows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Grails Webflows" Watch "Grails Webflows" New topic
Author

Grails Webflows

Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
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

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Grails Webflows