Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3754642
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:34:34+00:00 2026-05-19T09:34:34+00:00

Grails WebFlow noob here… One state in my WebFlow receives two events that need

  • 0

Grails WebFlow noob here…

One state in my WebFlow receives two events that need to trigger the same action and then transition to separate states if that action is successful. My initial attempt repeated the code in the actionState. Not good. So, after some trial and error, I came up with the following.

    state0 {
        on("event1") {
             flash.stateAfterNext = "state1"
        }.to "actionState"

        on("event2") {
            flash.stateAfterNext = "state2"
        }.to "actionState"
    }

    actionState {
        action {
            flow.unit = Unit.get(params.unit)
            success()
        }
        on("success").to { flash.stateAfterNext }
        on(Exception).to "home"
    }

    state1 { ... }

    state2 { ... }

This works but is it good Grails practice? Is there a better way to handle flow branching logic like this? In particular, should I have used a subflow here, and, if so, what would that look like?

Note: I attempted to move the code in actionState into a separate method but since it references flow that didn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:34:35+00:00Added an answer on May 19, 2026 at 9:34 am

    What about something like

    flow{    
        state0 {
            on("event1") {
                saveUnit(flow,params.unit)
            }.to "state1"    
            on("event2") {
                saveUnit(flow,params.unit)
            }.to "state2"
        }
        state1{...}
        state2{...}
    
    }
    
    private saveUnit(flow, unit){
        flow.unit = Unit.get(unit)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Grails vs Rails. Which has better support? And which one is a better choice
I'm still learning Grails and seem to have hit a stumbling block. Here are
I'm using Grails 1.1 beta2. I need to import a large amount of data
I have noticed that after my Grails app has been deployed for about 2
I am a newbie just started exploring Grails so that I can recommend this
Grails makes it very easy to configure datasources for different environments (development, test, production)
I did a grails clean and afterwards when I run via grails run-app the
In a Grails domain class, how do I set the constraint for a String
I'm learning Grails/GORM and as I've understood it the current best practice is not
I'm new to grails. I'd like to give it a whirl by implementing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.