f:all shows "Tag [all] currently only supports domain types" error for child domain objects
- 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{}
```
page edit.gsp for Charge contains
```
```
/_field/budgetIndex/_input.gsp contains
```
```
When I enter /charge/edit/1
I get "Tag [all] currently only supports domain types" error
The error is caused with the fact that 'value' is a hibernate proxy with class name
```
com.mycorp.aim.id.BudgetIndex_$$_javassist_34
```
This needs to be fixed.
I managed to solve this problem using HibernateProxyHelper, this is the code:
```
def fAll = { attrs, body ->
if (!attrs.bean) throwTagError("Tag [all] is missing required attribute [bean]")
def bean = resolveBean(attrs.bean)
def prefix = resolvePrefix(attrs.prefix)
def domainClass = resolveDomainClass(bean)
//-------------------------------------------------
if (!domainClass){
try{
def cl = HibernateProxyHelper.getClassWithoutInitializingProxy(bean)
domainClass = resolveDomainClass(cl)
}catch(e){
log.warn(e)
}
}
//-------------------------------------------------
if (domainClass) {
for (property in resolvePersistentProperties(domainClass, attrs)) {
out << f.field(bean: bean, property: property.name, prefix: prefix)
}
} else {
throwTagError("Tag [all] currently only supports domain types: $bean.")
}
}
```
Hope it helps.
Contributor guide
Research direction
Start by locating the f:all tag implementation and reviewing the _field/budgetIndex/_input.gsp usage shown in the report. Reproduce the failure at /charge/edit/1 with a Hibernate proxy, then verify that f:all accepts the child domain object without raising the domain-types error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100