Details
-
Type:
Sub-task
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.0.1
-
Fix Version/s: None
-
Component/s: TagLib, URL mappings
-
Labels:None
Description
Reverse lookup for a mapping like this:
"/api/books"(controller: "book") { action = [GET: "apiShow", POST: "apiNew"] }
doesn't work if you provide an 'action' attribute to any of the link generation tags. It only works if you leave 'action' out. This is pretty confusing, so it would be good if createLink(controller: "book", action: "apiNew") generated "/api/books".
To demonstrate the issue, unpack the attached bug report, run the application, and open the home page. The two "API ..." links displayed on the page link to a different location than "/api/books".
-
Hide
- url-mapping-changes-bug-report-23032012.zip
- 23/Mar/12 4:56 AM
- 26 kB
- Peter Ledbrook
-
- grails-app/conf/.UrlMappings.groovy.swp 12 kB
- grails-app/.../ApplicationResources.groovy 0.1 kB
- grails-app/conf/BootStrap.groovy 0.4 kB
- grails-app/conf/BuildConfig.groovy 2 kB
- grails-app/conf/Config.groovy 4 kB
- grails-app/conf/DataSource.groovy 1 kB
- grails-app/conf/UrlMappings.groovy 1 kB
- grails-app/conf/spring/resources.groovy 0.0 kB
- grails-app/.../BookController.groovy 0.2 kB
- grails-app/.../ErrorController.groovy 0.1 kB
- grails-app/.../RepositoryController.groovy 0.2 kB
- grails-app/.../SomeController.groovy 0.2 kB
- grails-app/.../TestController.groovy 0.2 kB
- grails-app/domain/.../example/Book.groovy 0.2 kB
- grails-app/i18n/messages.properties 3 kB
- grails-app/.../messages_cs_CZ.properties 3 kB
- grails-app/i18n/messages_da.properties 3 kB
- grails-app/i18n/messages_de.properties 4 kB
- grails-app/i18n/messages_es.properties 3 kB
- grails-app/i18n/messages_fr.properties 2 kB
- grails-app/i18n/messages_it.properties 2 kB
- grails-app/i18n/messages_ja.properties 4 kB
- grails-app/i18n/messages_nl.properties 3 kB
- grails-app/.../messages_pt_BR.properties 3 kB
- grails-app/.../messages_pt_PT.properties 3 kB
- grails-app/i18n/messages_ru.properties 4 kB
- grails-app/i18n/messages_sv.properties 3 kB
- grails-app/i18n/messages_th.properties 6 kB
- grails-app/.../messages_zh_CN.properties 2 kB
- grails-app/views/error.gsp 0.3 kB
Issue Links
- is related to
-
GRAILS-9326
default controller name not applied, custom mapping in URLMappings applied
-
-
GRAILS-2843
Form tag doesn't generate correct URL when REST-ful HTTP protocol is used
-
-
GRAILS-4588
reverse URL mapping breaks in controllers with alternate REST mappings
-
- relates to
-
GRAILS-2843
Form tag doesn't generate correct URL when REST-ful HTTP protocol is used
-
-
GRAILS-5207
Reverse URL mappings / redirect to REST url mapping fails
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
I think the main problem here is because grails "enforces you" in some way to use createLink, redirect,... using controller/action values instead of using named URLs.
I think that the default use should be creating a named URL and use it in all the application. There are only advantages:
- Easy refactors for controllers. It is only necessary to change the action in the URL mappings file and not in all controllers and GSPs.
- Write less code. You only write createLink(mapping:'myMapping') instead of createLink (controller:'myController',action:'myAction')
As a final thought, in all our grails project we always use named URLs because we have leant from our previous errors in others projects.
GRAILS-2843 is a specific instance of this, or is at least closely related.