Results 1 to 1 of 1

Thread: Accessing flow frm flow scoped service

  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Default Accessing flow frm flow scoped service

    Hello I am relative new to Grails and struggle using webflow. I created a flow scoped service
    Code:
    class MyService implements Serializable{
        
        static scope = "flow"
        static transactional = false
            
        def counter = 0
        
        def serviceMethod() {
            this.counter++
            log.debug("SERVICE METHOD CALLED ${this.counter} times")
             
        }
    ...
    I call this service from a controller web flow
    Code:
    ...
    stepTwo {
                on("previous") {
                    flow.myVar="HELLO"
                    log.debug("JUST HIT previous at STEP TWO")
                    myService.serviceMethod()
                }.to("processOne")
                on("cancel").to("finish")
                on("finish"){
                    log.debug("JUST HIT finish at STEP TWO")
                    myService.serviceMethod()
                }.to("finish")
            }
    ...
    I was under the impression that I would be able to access flow scoped variables in my service using

    Code:
      println flow.myVar
    But I can't seem to access the flow object. I get a "No such property: flow for class: MyService". Does anybody know if this is the correct behavior or a bug? I read "Grails in Action" and the book also shows such an example.
    Last edited by soappatrol; Jun 1st, 2012 at 12:30 AM. Reason: typo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •