Benjamin Pavie
2014-05-15 12:24:17 UTC
Dear All,
I wanted to be able to extends RestfulController in order to modify the save
method.
However, at least on grails 2.3.7, extending RestfulController make the Save
methode not accessible anymore (using the @Resource annotation works)
Here is a code sample with @Resource (=> Work)
Then the curl command to test it:
Now, I try to NOT use the @Resource annotation and instead create a
controller that extends the RestfulController:
Test .groovy
TestController.groovy:
And the UrlMappings:
And the curl request and result:
So it is seems to be readonly by default.
According to the RestfulController source code, we should be able to pass a
boolean to the constructor so it won't be read-only (see
https://github.com/grails/grails-core/blob/master/grails-plugin-rest/src/main/groovy/grails/rest/RestfulController.groovy#L194
)
So I modified the TestController like that:
TestController.groovy:
But still have the same output (not creating)
For information, getting the list of item using curl ( curl -i -H
"Content-Type:application/json" http://localhost:8080/labData/data/test )
seems to work.
Upgrading to 2.3.8 is not an option due to a similar bug affecting the
domain using the @Resource annotation (see my previous post :
http://grails.1312388.n4.nabble.com/Updating-from-2-3-7-to-2-3-8-generate-issue-with-REST-API-tc4656486.html
) and the corresponding JIRA https://jira.grails.org/browse/GRAILS-11354 .
So is there a way to be able to create and use the extends RestfulController
? And if yes how to do that? Or is it new bug and which version of grails
should I use?
Thanks,
Benjamin
--
View this message in context: http://grails.1312388.n4.nabble.com/Extends-RestfulController-and-create-item-in-grails-2-3-7-tp4656902.html
Sent from the Grails - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
I wanted to be able to extends RestfulController in order to modify the save
method.
However, at least on grails 2.3.7, extending RestfulController make the Save
methode not accessible anymore (using the @Resource annotation works)
Here is a code sample with @Resource (=> Work)
Then the curl command to test it:
Now, I try to NOT use the @Resource annotation and instead create a
controller that extends the RestfulController:
Test .groovy
TestController.groovy:
And the UrlMappings:
And the curl request and result:
So it is seems to be readonly by default.
According to the RestfulController source code, we should be able to pass a
boolean to the constructor so it won't be read-only (see
https://github.com/grails/grails-core/blob/master/grails-plugin-rest/src/main/groovy/grails/rest/RestfulController.groovy#L194
)
So I modified the TestController like that:
TestController.groovy:
But still have the same output (not creating)
For information, getting the list of item using curl ( curl -i -H
"Content-Type:application/json" http://localhost:8080/labData/data/test )
seems to work.
Upgrading to 2.3.8 is not an option due to a similar bug affecting the
domain using the @Resource annotation (see my previous post :
http://grails.1312388.n4.nabble.com/Updating-from-2-3-7-to-2-3-8-generate-issue-with-REST-API-tc4656486.html
) and the corresponding JIRA https://jira.grails.org/browse/GRAILS-11354 .
So is there a way to be able to create and use the extends RestfulController
? And if yes how to do that? Or is it new bug and which version of grails
should I use?
Thanks,
Benjamin
--
View this message in context: http://grails.1312388.n4.nabble.com/Extends-RestfulController-and-create-item-in-grails-2-3-7-tp4656902.html
Sent from the Grails - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email