apache / apache/grails-core

f:table collection is generating invalid hyperlinks in Grails 3.3.2

Open
#14,235 0 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-fields
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Hello There,

I have unidirectional Domain class in my project, List page generated with invalid hyperlinks.
`com.sample.Child : 1`

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

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
`com.sample.Child : 1`

/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
`${fieldValue(bean: parentInstance, field: "child")}`

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

Contributor guide

Open the contributing guide

Research direction

Reproduce the Grails 3.3.2 app using the listed domain classes, generated controllers and views, then inspect parent/index.gsp and its output. Compare it with the Grails 2.x g:each example; done means the parent link renders without a nested child hyperlink and still points to /parent/show/1.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.