Grails 2 controller scaffold: how to override a template method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 2 controller scaffold: how to override a template method

basejump (Josh)
This used to work pre Grails 2.
Lets say I have a controller template
class ${className}Controller {
   
   def prepareParams(){
      params.sup = "sup dog?"
   }
   
   def edit(){
      prepareParams()
      ...
   }
   ...
}

and I want to replace prepareParams() in my controller

class SupDogController(){
   static scaffold = SupDog
   
   def prepareParams(){
      params.sup = "sup wit you?"
   }
}

sup is always "sup dog?"

is there a way to override the scaffold methods or access the actual controller instance's method?



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Grails 2 controller scaffold: how to override a template method

tomas lin
Yes, make them into closures. 

Because of this - http://fbflex.wordpress.com/2012/11/26/a-subtle-difference-between-closures-and-closures-in-groovy/ 

On Sun, Jan 27, 2013 at 7:50 PM, Josh (basejump) <[hidden email]> wrote:
This used to work pre Grails 2.
Lets say I have a controller template
class ${className}Controller {

   def prepareParams(){
      params.sup = "sup dog?"
   }

   def edit(){
      prepareParams()
      ...
   }
   ...
}

and I want to replace prepareParams() in my controller

class SupDogController(){
   static scaffold = SupDog

   def prepareParams(){
      params.sup = "sup wit you?"
   }
}

sup is always "sup dog?"

is there a way to override the scaffold methods or access the actual controller instance's method?



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Grails 2 controller scaffold: how to override a template method

basejump (Josh)
Yup, you nailed it with that example. 
I think we jumped the gun and converted to methods instead of closure actions. changing all the actions back to closures did the trick and our scaffolding works as it once did pre 2.

On Jan 27, 2013, at 1:58 PM, Tomas Lin wrote:

Yes, make them into closures. 

Because of this - http://fbflex.wordpress.com/2012/11/26/a-subtle-difference-between-closures-and-closures-in-groovy/ 

On Sun, Jan 27, 2013 at 7:50 PM, Josh (basejump) <[hidden email]> wrote:
This used to work pre Grails 2.
Lets say I have a controller template
class ${className}Controller {

   def prepareParams(){
      params.sup = "sup dog?"
   }

   def edit(){
      prepareParams()
      ...
   }
   ...
}

and I want to replace prepareParams() in my controller

class SupDogController(){
   static scaffold = SupDog

   def prepareParams(){
      params.sup = "sup wit you?"
   }
}

sup is always "sup dog?"

is there a way to override the scaffold methods or access the actual controller instance's method?



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email