Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.0.RC1 - f:table does not respect namespace controllers #303

Open
codeconsole opened this issue Jun 5, 2019 · 5 comments
Open

3.0.0.RC1 - f:table does not respect namespace controllers #303

codeconsole opened this issue Jun 5, 2019 · 5 comments

Comments

@codeconsole
Copy link
Contributor

Links generated with f:table do not respect namespaces (All other generated tags work).

Replication Example (Grails 4.0.0.RC1):
https://github.com/codeconsole/formbinding

git clone https://github.com/codeconsole/formbinding
cd formbinding
sdk use grails 4.0.0.RC2 
grails run-app

Go here:
http://localhost:8080/v3/person/index

Click on Name column in table and notice you will be sent here:
http://localhost:8080/person/index?sort=name&max=10&order=asc

Which is not in the v3 namepace and is an invalid url.
static namespace = 'v3'

@codeconsole
Copy link
Contributor Author

I imagine it is a fairly simple fix as g:link tags support the namespace property and you simply need to change

<g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link>

to

<g:link namespace="${c.namespace}" controller="${c.logicalPropertyName}">${c.fullName}</g:link>

If the controller has no namespace, the link tag will still work as normal.

@codeconsole
Copy link
Contributor Author

grails/grails-core#10819

@codeconsole
Copy link
Contributor Author

If there is no plan in place to fix g:sortableColumn, this plugin should be updated to not use g:sortableColumn in table generation. I would recommend just not allowing the user to sort the column as the current behavior is completely broken,

@codeconsole
Copy link
Contributor Author

https://github.com/grails-fields-plugin/grails-fields/blob/master/grails-app/views/templates/_fields/_table.gsp

if the template passes the namespace to the g:sortableColumn, everything works fine except non namespace resources (which do not work either way). Interestingly enough, adding namespace makes namespaced resources work great.

Here is a fix, but might not be the most efficient way of accomplishing it:

change g:sortableColumn from:

<g:sortableColumn property="${p.property}" title="${p.label}" />

to

<g:sortableColumn namespace="${grailsApplication.controllerClasses.findResult{it.logicalPropertyName == controllerName?it.namespace:null}?:''}" property="${p.property}" title="${p.label}" />

@fuxx
Copy link

fuxx commented Jul 17, 2019

I made a pull request on gsp for 3.3.x which gets hopefully merged so we don't need a workaround.
grails/grails-gsp#45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants