开发者

mapping a grails action to a parent controller

I would like to map some actions in a child class to their super class, but I cannot figure it out. Example below...

abstract class A {
    abstract def foo()开发者_如何学Python

    def aAction1 = {
       // do something
       render(view: '/someView')
    }
    def aAction2 = { 
       SomeObject someObject ->
       // do something
       render(view: '/someView2')
    }
}

class B extents A {
    def foo() { return "Hello World" }

    # map to parent action    
    # works fine
    def jump = super.&aAction1
    # doesnt work ... Why? and can I make it work?
    def swim = { SomeObject someObject ->
       super.aAction2(someObject)
    }
}

Any ideas on this one? Thanks.


So it turns out it didnt work because the parameters were slightly different. It does seem to work as expected. If you are having issues with this, make sure that the parameters for any inherited classes are exactly the same as the parent.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜