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

f:table collection is generating invalid hyperlinks in Grails 3.3.2 #15

Closed
akusuma2026 opened this issue Jan 19, 2018 · 0 comments
Closed

Comments

@akusuma2026
Copy link

Hello There,

I have unidirectional Domain class in my project, List page generated with invalid hyperlinks.
<td><a href="/parent/show/1"><a href="/child/show/1">com.sample.Child : 1</a></a></td>

Steps to re-produce the issue

Grails 3.3.2
grails create-app Grails3-UniDirectional-Relationship
grails create-domain-class com.sample.Child
grails create-domain-class com.sample.Parent

Add two properties in Child class
package com.sample
class Child {

String name
String description

static constraints = {
}

}

Add Child property in Parent class like below
package com.sample
class Parent {

//Parent - to - Child (One-To-One) UniDirectional
Child child
static constraints = {
}

}

Generare controllers and views
grails generate-all com.sample.Child
grails generate-all com.sample.Parent

check: parent/index.gsp has <f:table collection="${parentList}" />

Run-app
grails run-app or Run Application.groovy

Add new child
http://localhost:8080/child/create
give values for name and desctiption

Add new parent
http://localhost:8080/parent/create
select a child* (created earlier) and save

Now go to Parent list page
http://localhost:8080/parent/index

List page has Child1 Which has hyperlink of Child1
If you click that , it leads to http://localhost:8080/child/show/1 instead of http://localhost:8080/parent/show/1

See view-source of Parent list page (view-source:http://localhost:8080/parent/index),
you will find like this
<td><a href="/parent/show/1"><a href="/child/show/1">com.sample.Child : 1</a></a></td>

/parent/show/1 override by /child/show/1

if we repeat this in Grails 2.4.4 or any 2.x version
parent/index.gsp has below tag to list the values and its working fine
<g:each in="${parentInstanceList}" status="i" var="parentInstance"><tr class="${(i % 2) == 0 ? 'even' : 'odd'}"><td><g:link action="show" id="${parentInstance.id}">${fieldValue(bean: parentInstance, field: "child")}</g:link></td></tr></g:each>

Please suggest how can we disable or not to appear child hyperlink (/child/show/1). Or any fix for this in Grails 3.3.2

Thanks

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

1 participant