Showing posts with label grails. Show all posts
Showing posts with label grails. Show all posts

Wednesday, April 06, 2011

Grails: Securing CKEditor URLs

Problem:
I am using the grails CKEditor plugin and i wanted to secure the file manager urls to be accessed only by a site admin. I am using the Spring Security Core plugin for site security, but i was already using annotations elsewhere on my site, so using a InterceptUrlMap was not an option.

So, how to keep using annotations and secure a plugin's urls?

Solution:
The trick is properly using the controllerAnnotations.staticRules (which really isnt that hard if you pay attention to the docs).
Here is the mapping that works for ANY url mapping you define to CKEditor:



Thursday, March 24, 2011

manually set id of grails domain object

Problem:
if you create a new domain object and set its id in the constructor like this:
Cat catman = new Cat(id:1000, name: "catman", kind: "domestic short haired")
later, if you look at the object the id will be null. what gives?!


Solution:
Its madness, but it works to assign the id after the object is made. Just add
catman.setId(1000);
and you are in business.

Note: if you want to save the object into db after doing this, you must set the id generator to 'assigned'