Grails Web Flow first state

◇◆丶佛笑我妖孽 提交于 2019-12-24 17:56:01

问题


A few questions about the first state of a Grails web flow:

  1. Is it possible to have multiple start states?
  2. Is it possible for the first state to be an action state?
  3. Assuming the answer to (2) is no, what are my options for passing data to the first (view) state? I could store it in the session beforehand, but this isn't very appealing because I would need to take care of removing it myself. Ideally I'd like to store the data in flow scope before the first (view) state is displayed, but I don't see how this is possible

回答1:


You can have an action state as the first state in a webflow and you can pass parameters in to it as any other controller action and get them with 'params.paramName'.

def createNewSubscriptionFlow= {
    initialState {
        action {
           ...

Then grab the data you need and store in flow scope(Needs to be serializable!) as you state.

In answer to 1, I don't think you can have multiple start states but you could make your initial action state decide what state to move to.

Thanks,

Jim.




回答2:


You also can to use the onStart event

def csikszentmihalyiFlow = {
    onStart doSomethingClosure
....
}

doSomethingClosure = {
    def doSome = new Thing()
}


来源:https://stackoverflow.com/questions/7158042/grails-web-flow-first-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!