|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
FW: [grails-user] What's the proper way to invoke super.beforeInsert() for a Domain class?I asked this question on the Grails user list but perhaps it's more of a
Groovy question. How to I invoke a super class's closure that has the same name as "this" class's closure? -----Original Message----- From: Lachman, Matt (West) Sent: Friday, November 06, 2009 3:01 PM To: user@... Subject: [grails-user] What's the proper way to invoke super.beforeInsert() for a Domain class? I have domain classes similar to the following: class A { //Some properties def beforeInsert = { //Do something interesting } } class B extends A { //Some added properties def beforeInsert = { super.beforeInsert() //doesn't actually call A.beforeInsert() //Do additional interesting things } } What's the proper way to achieve the effect I'm looking for? Thanks, Matt --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: FW: [grails-user] What's the proper way to invoke super.beforeInsert() for a Domain class?You can do it like:
================================= class A { def beforeInsert = { println "A->beforeInsert()" } } class B extends A { def getSuperClosure() { super.getBeforeInsert() } def beforeInsert = { getSuperClosure()() println "B->beforeInsert()" } } new B().beforeInsert() ================================= Hope it helps. -- Roshan On Sat, Nov 7, 2009 at 2:40 AM, <Matthew.Lachman@...> wrote: I asked this question on the Grails user list but perhaps it's more of a |
|
|
RE: FW: [grails-user] What's the proper way to invoke super.beforeInsert() for a Domain class?Good
idea – I’ll give that a shot. On the Grails list, I also got
the following suggestion from Burt Beckwith: Have beforeInsert delegate to a
real method: class A { //Some properties protected void
onBeforeInsert() {
//Do something interesting } def beforeInsert =
{
onBeforeInsert() } } class B extends A { //Some added
properties @Override protected void
onBeforeInsert() {
super.onBeforeInsert()
//Do additional interesting things } } Both
seem obvious now that I see them. Thanks! Matt From:
roshandawrani@... [mailto:roshandawrani@...] On Behalf Of Roshan
Dawrani You can do it like: On Sat, Nov 7, 2009 at 2:40 AM, <Matthew.Lachman@...>
wrote: I asked this question on the
Grails user list but perhaps it's more of a |
| Free embeddable forum powered by Nabble | Forum Help |