- Previous thread: Re: [grails-user] strange Grails 1.2 upgrade problem with GSP resolution -- SOLVED
- Next thread: [grails-user] How to use List for domain mapping without error
- Threads sorted by date: grails 200909
Hi,
I'd like to be able to apply an action to the controllers in an application
via a plugin. I've read that in order to do this you've got to define a
get'MyActionName' method on the controller and return a closure from the
method - is this correct?
I've tried this using the follow code:
def doWithDynamicMethods = { ctx ->
application.controllerClasses.each { cClass ->
println "Controller class = $cClass.name"
cClass.metaClass.getHello = { ->
def hello = {
render "Hello"
}
return hello
}
println cClass.metaClass.methods*.name
}
}
When I look at the methods that have been added to the controller I can see
my new getHello method defined, but when I attempt to call the action I get
a 404 - 'The requested resource is not available'.
Can anyone give me any pointers to where I might be going wrong?
Thanks in advance,
rob
--
View this message in context: http://www.nabble.com/Applying-actions-to-controllers-with-doWithDynamicMethods-tp25478827p25478827.html
Sent from the grails - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
> When I look at the methods that have been added to the controller I can see
> my new getHello method defined, but when I attempt to call the action I get
> a 404 - 'The requested resource is not available'.
>
> Can anyone give me any pointers to where I might be going wrong?
Unless something has changed, you can't dynamically add actions
because Grails looks for a real closure property using bean
introspection. Could your plugin not simply provide its own
controller(s) and actions?
Cheers,
Peter
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
> my new getHello method defined, but when I attempt to call the action I get
> a 404 - 'The requested resource is not available'.
>
> Can anyone give me any pointers to where I might be going wrong?
Unless something has changed, you can't dynamically add actions
because Grails looks for a real closure property using bean
introspection. Could your plugin not simply provide its own
controller(s) and actions?
Cheers,
Peter
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Hi Peter,
Thanks for the info.
Yes, my plugin could provide it's own controller(s) and actions. TBH, I was
just exploring the capabilities of the doWith* closures and thought that
this might a simple way to do it.
Cheers,
r.
Peter Ledbrook wrote:
>
>> When I look at the methods that have been added to the controller I can
>> see
>> my new getHello method defined, but when I attempt to call the action I
>> get
>> a 404 - 'The requested resource is not available'.
>>
>> Can anyone give me any pointers to where I might be going wrong?
>
> Unless something has changed, you can't dynamically add actions
> because Grails looks for a real closure property using bean
> introspection. Could your plugin not simply provide its own
> controller(s) and actions?
>
> Cheers,
>
> Peter
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
>
--
View this message in context: http://www.nabble.com/Applying-actions-to-controllers-with-doWithDynamicMethods-tp25478827p25487189.html
Sent from the grails - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Related Threads
- ACCASTILLAGE SHIP MARINE - openbsd
- [users] This week plus next week in one iCal-space ? - openoffice
- [jira] Created: (OFBIZ-2754) Order Entry - Add / Update Order Terms Functionality Broken - ofbiz
- view/form with fields from multiple models - django
- [Red5] Question about restricting access to a stream - osflash
- Nginx for performance, with suhosin - nginx
- [webkit-dev] NeverNull<T> - webkit
- Fedora 11 installation on Thinkpad X31- Unstable tsc - fedora