Comparator.Constructors [0] .NewInstance ([DomaiNClass] em Grails 3
<table class="table table-striped">
<thead>
<tr>
<%
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()) {
%><th class="header"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></th><%
} else {
%><g:sortableColumn property="${p.name}" title="\${message(code: '${domainClass.propertyName}.${p.name}.label', default: '${p.naturalName}')}" /><%
}
}
}%>
<th></th>
</tr>
</thead>
<tbody>
<g:each in="\${${propertyName}List}" var="${propertyName}">
<tr>
<% props.eachWithIndex { p, i ->
if (i < 6) {
if (p.type == Boolean || p.type == boolean) { %>
<td><g:formatBoolean boolean="\${${propertyName}.${p.name}}" /></td>
<% } else if (p.type == Date || p.type == java.sql.Date || p.type == java.sql.Time || p.type == Calendar) { %>
<td><g:formatDate date="\${${propertyName}.${p.name}}" /></td>
<% } else { %>
<td>\${fieldValue(bean: ${propertyName}, field: "${p.name}")}</td>
<% } } } %>
<td class="link">
<div class="btn-group btn-group-xs">
<g:link action="show" id="\${${propertyName}.id}" class="btn btn-primary btn-sm" role="button">
<span class="glyphicon glyphicon-eye-open"></span>
<g:message code="default.button.show.label" default="Show" />
</g:link>
<g:link action="edit" id="\${${propertyName}.id}" class="btn btn-primary btn-sm" role="button">
<span class="glyphicon glyphicon-pencil"></span>
<g:message code="default.button.edit.label" default="Edit" />
</g:link>
</div>
</td>
</tr>
</g:each>
</tbody>
</table>
Disgusted Duck