开发者

Accessing flow scope in grails service

I have and WebFlow in my controller, and simple flow-scoped service. Somewhere close to the end of my web flow, I need to validate my command object field against value I received earlier in the web flow. For this I created a simple flow-scoped service:

class EventFlowService implements Serializable {

    static transactional = false

    static scope = "flow"

    Date getEventStartDate(){
        flow.basicData.eventDate
    }
}

I don't need my service anywhere else than in a command object, so I inject it to my command object, like so:

class EventRestrictionsCommand implements Serializable{

    def eventFlowService

    boolean onlineRegistration
    Date onlineRegistrationEnd
    Date onlineRegistrationStart

    static constraints = {

        onlineRegistrationEnd validator: {val, obj ->
            if(obj.onlineRegistration){
                return val > obj.onlineRegistrationStart || val <= obj.eventFlowService.getEventStartDate()
            }
            return null
        }    
    }    
}

The problem is that I get exception saying, that there is no flow property in my service. Is th开发者_开发问答ere any way I can get access to flow storage in my flow-scoped service?


I met the SAME issue before and worked it out by installing webflow plugin in GRAILS:

grails install-plugin webflow

Say, the new version of grails surports webflow well by installing webflow plugin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜