Associations and the Grails webflow

Posted by callie16 on Stack Overflow See other posts from Stack Overflow or by callie16
Published on 2010-04-23T09:10:12Z Indexed on 2010/04/23 9:13 UTC
Read the original article Hit count: 371

Filed under:
|
|

Hi, it's my first time using webflows in Grails and I can't seem to solve this.

I have 3 domain classes with associations that look something like this:

class A {
  ...
  static hasMany = [ b : B ]
  ...
}

class B {
  ...
  static belongsTo = [ a : A ]
  static hasMany = [ c : C ]
  ...
}

class C {
  ...
  static belongsTo = [ b : B ]
  ...
}

Now, the GSP communicates with the controller via Javascript (due to my use of Dojo). When I try to remoteFunction a normal action, I can do something like this:

def action1 = {
   def anId = params.id
   def currA = A.get(anId)
   def sample = currA.b?.c // I can get all the way to 'c' without any problems
   ...
}

However, I have a webflow and the contents of that action is in the webflow... It looks something like this:

def someFlow = {
   ...
   someState {
      on("next") {
         def anId = params.id // this does NOT return a null value
         def currA = A.get(anId) // this does NOT return a null value
         def sample = currA.b // error already occurs here and I need to get 'c'!
      }.("somePage")
      ...
   }
   ...
}

In this case, it tells me that b doesn't exist... so I can't even get to 'c'. Any suggestions on what to do??? Thanks... getting real desperate...

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about grails