KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can I dynamically build a list of mappings - instead of: class UrlMappings { static mappings = { "/helpdesk/user/$action?/$id?" (controller="helpdeskuser") "/helpdesk/group/$action?/$id?" (controller="helpdeskgroup") "/helpdesk/company/$action?/$id?" (controller="helpdeskcompany") "/helpdesk/account/$action?/$id?" (controller="helpdeskaccount") "/admin/company/$action?/$id?" (controller="admincompany") "/admin/account/$action?/$id?" (controller="adminaccount") } } something like this pseudo code: class UrlMappings { static mappings = { application.controllerClasses.each { if(it.name.startsWith('helpdesk')) "/helpdesk/${it.name}/$action?/$id?" (controller="${it.name}") if(it.name.startsWith('admin')) "/admin/${it.name}/$action?/$id?" (controller="${it.name}") } } } (I don't understand what the static mappings are - a hash map? free variables?) What I am trying to achieve are mappings based on the controller type - e.g. helpdesk, admin or user controllers. Once I have set up the mappings I want to add security based on URLs but I don't want to map each controller individually: grails.plugins.springsecurity.interceptUrlMap = [ '/helpdesk/**': ['ROLE_HELPDESK','ROLE_ADMIN'], ]
Tags (comma-separated)
Save Edits
Cancel