Google is a good teacher when you meet trouble. But I can google nothing. It seems that there is not any thread about my question. So, I checked grails api and found two things:
1. GrailsControllerClass does not provide a method to list all actions.
2. But GrailsControllerClass has a method to list all its possible URIs: getURIs().
Since an URI is a combination of controller and action in grails, finally, I solved my problem using that method. Here is my solution:
def actions= []
grailsApplication.getArtefact(ControllerArtefactHandler.TYPE, your controller name).URIs.each{
def parts= it.split('/')
if(parts.size()>2){
actions << parts[2]
}
}
return (actions as Set)
By the way, Grails JSecurity Plugin is awesome! It reallys makes my life easier!
No comments:
Post a Comment