apache / apache/grails-core

f:all does not resolve label keys properly for child domain objects

Open
#14,242 1 comment 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 I have domains like this:

```
Charge{
BudgetIndex budgetIndex
}
BudgetIndex{
PaymentEnumType paymentType
}
```

page edit.gsp for Charge contains

```

```

/_field/budgetIndex/_input.gsp contains

```

```

When I enter /charge/edit/1
I see that labels for bean budgetIndex are defaults, not the ones I specified in message.properties.

Digging into the problem shows that this is because label is resolved with incorrect code

```
budgetIndex_$$_javassist_10.paymentType.label
```

The message code should have been:

```
budgetIndex.paymentType.label
```

Again, this is because of hibernate proxy objects.

To see the code I added println here:

```
private String resolveMessage(List keysInPreferenceOrder, String defaultMessage) {
def message = keysInPreferenceOrder.findResult { key ->
println "key = $key"
message(code: key, default: null) ?: null
}
message ?: defaultMessage
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the f:all tag and the resolveMessage method shown in the report, then reproduce the nested Charge and BudgetIndex form at /charge/edit/1. Compare the label keys produced for the child bean with the message.properties key, and verify that the expected label is used without the proxy-class suffix.

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
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.