fields
fields copied to clipboard
f:all shows "Tag [all] currently only supports domain types" error for child domain objects
Hello I have domains like this:
Charge{
BudgetIndex budgetIndex
}
BudgetIndex{}
page edit.gsp for Charge contains
<f:all bean="chargeInstance"/>
/_field/budgetIndex/_input.gsp contains
<f:all bean="${value}"/>
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.
See comment in PR