Skip to content

Commit

Permalink
Use default Bean domainPropertyFactory provided by Scaffolding Plugin
Browse files Browse the repository at this point in the history
Change `fieldsDomainPropertyFactory` to `domainPropertyFactory`

Closes gh-3
  • Loading branch information
rainboyan committed Sep 27, 2024
1 parent 62af282 commit 6d65012
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FormFieldsTagLib {

FormFieldsTemplateService formFieldsTemplateService
BeanPropertyAccessorFactory beanPropertyAccessorFactory
DomainPropertyFactory fieldsDomainPropertyFactory
DomainPropertyFactory domainPropertyFactory

@Autowired(required = false)
Collection<MappingContext> mappingContexts
Expand Down Expand Up @@ -546,7 +546,7 @@ class FormFieldsTagLib {
}
def orderBy = getList(attrs.order)
properties = orderBy.collect { propertyName ->
fieldsDomainPropertyFactory.build(domainClass.getPropertyByName(propertyName))
domainPropertyFactory.build(domainClass.getPropertyByName(propertyName))
}
} else {
properties = list ? domainModelService.getListOutputProperties(domainClass) : domainModelService.getInputProperties(domainClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BeanPropertyAccessorFactory implements GrailsApplicationAware {
private ProxyHandler proxyHandler

@Autowired
private DomainPropertyFactory fieldsDomainPropertyFactory
private DomainPropertyFactory domainPropertyFactory

@Autowired
private MappingContext grailsDomainClassMappingContext
Expand Down Expand Up @@ -107,7 +107,7 @@ class BeanPropertyAccessorFactory implements GrailsApplicationAware {
}

if (persistentProperty != null) {
fieldsDomainPropertyFactory.build(persistentProperty)
domainPropertyFactory.build(persistentProperty)
} else {
params.entity = beanClass
params.beanType = beanWrapper.wrappedClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ package grails.plugin.formfields

import grails.plugins.Plugin

import org.grails.scaffolding.model.property.DomainPropertyFactoryImpl

class FieldsGrailsPlugin extends Plugin {

static final String CONSTRAINTS_EVALULATOR_BEAN_NAME = 'validateableConstraintsEvaluator'
Expand All @@ -31,6 +29,5 @@ class FieldsGrailsPlugin extends Plugin {
Closure doWithSpring() {{->
beanPropertyAccessorFactory(BeanPropertyAccessorFactory)
formFieldsTemplateService(FormFieldsTemplateService)
fieldsDomainPropertyFactory(DomainPropertyFactoryImpl)
}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class BuildsAccessorFactory extends Specification implements GrailsWebU
constraintsEvaluator = ref(FieldsGrailsPlugin.CONSTRAINTS_EVALULATOR_BEAN_NAME)
proxyHandler = new DefaultProxyHandler()
grailsDomainClassMappingContext = ref("grailsDomainClassMappingContext")
fieldsDomainPropertyFactory = dpf
domainPropertyFactory = dpf
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ abstract class AbstractFormFieldsTagLibSpec extends Specification implements Gra
grailsTagDateHelper(DefaultGrailsTagDateHelper)
//constraintsEvaluator(DefaultConstraintEvaluator)
def dpf = new DomainPropertyFactoryImpl(grailsDomainClassMappingContext: applicationContext.getBean("grailsDomainClassMappingContext", MappingContext), trimStrings: true, convertEmptyStringsToNull: true)
fieldsDomainPropertyFactory(InstanceFactoryBean, dpf, DomainPropertyFactory)
domainPropertyFactory(InstanceFactoryBean, dpf, DomainPropertyFactory)

domainModelService(DomainModelServiceImpl) {
domainPropertyFactory = ref('fieldsDomainPropertyFactory')
domainPropertyFactory = ref('domainPropertyFactory')
}
beanPropertyAccessorFactory(BeanPropertyAccessorFactory) {
constraintsEvaluator = ref(FieldsGrailsPlugin.CONSTRAINTS_EVALULATOR_BEAN_NAME)
proxyHandler = new DefaultProxyHandler()
grailsDomainClassMappingContext = ref("grailsDomainClassMappingContext")
fieldsDomainPropertyFactory = ref('fieldsDomainPropertyFactory')
domainPropertyFactory = ref('domainPropertyFactory')
}
}
}
Expand Down

0 comments on commit 6d65012

Please sign in to comment.