📅  最后修改于: 2022-03-11 15:04:50.231000             🧑  作者: Mango
<%
def grailsApplication = grails.util.Holders.grailsApplication
domainObjetc = grailsApplication.domainClasses.find { it.clazz.simpleName == className }.clazz.newInstance()
domainClass= grailsApplication.getDomainClass(domainObjetc.class.name)
excludedProps = grails.persistence.Event.allEvents.toList() << 'id' << 'version'
allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && it.type != null && !Collection.isAssignableFrom(it.type) }
comparator = new org.grails.validation.DomainClassPropertyComparator(domainClass)
Collections.sort(props, comparator)
props.eachWithIndex { p, i ->
if (i < 6) {
if (p.isAssociation()) {
%> <%
} else {
%> <%
}
}
}%>
<% props.eachWithIndex { p, i ->
if (i < 6) {
if (p.type == Boolean || p.type == boolean) { %>
<% } else if (p.type == Date || p.type == java.sql.Date || p.type == java.sql.Time || p.type == Calendar) { %>
<% } else { %>
\${fieldValue(bean: ${propertyName}, field: "${p.name}")}
<% } } } %>