% if (property.type == Boolean.class || property.type == boolean.class)
out << renderBooleanEditor(domainClass, property)
else if (Number.class.isAssignableFrom(property.type) || (property.type.isPrimitive() && property.type != boolean.class))
out << renderNumberEditor(domainClass, property)
else if (property.type == String.class)
out << renderStringEditor(domainClass, property)
else if (property.type == Date.class || property.type == java.sql.Date.class || property.type == java.sql.Time.class || property.type == Calendar.class)
out << renderDateEditor(domainClass, property)
else if (property.type == URL.class)
out << renderStringEditor(domainClass, property)
else if (property.isEnum())
out << renderEnumEditor(domainClass, property)
else if (property.type == TimeZone.class)
out << renderSelectTypeEditor("timeZone", domainClass, property)
else if (property.type == Locale.class)
out << renderSelectTypeEditor("locale", domainClass, property)
else if (property.type == Currency.class)
out << renderSelectTypeEditor("currency", domainClass, property)
else if (property.type==([] as Byte[]).class) //TODO: Bug in groovy means i have to do this :(
out << renderByteArrayEditor(domainClass, property)
else if (property.type==([] as byte[]).class) //TODO: Bug in groovy means i have to do this :(
out << renderByteArrayEditor(domainClass, property)
else if (property.manyToOne || property.oneToOne)
out << renderManyToOne(domainClass, property)
else if ((property.oneToMany && !property.bidirectional) || (property.manyToMany && property.isOwningSide()))
out << renderManyToMany(domainClass, property)
else if (property.oneToMany)
out << renderOneToMany(domainClass, property)
private renderEnumEditor(domainClass, property) {
return ""
}
private renderStringEditor(domainClass, property) {
if (!cp) {
return ""
}
else {
if ("textarea" == cp.widget || (cp.maxSize > 250 && !cp.password && !cp.inList)) {
return ""
}
else {
if (cp.inList) {
return ""
}
else {
def sb = new StringBuffer(""
return sb.toString()
}
}
}
}
private renderByteArrayEditor(domainClass, property) {
return ""
}
private renderManyToOne(domainClass,property) {
if (property.association) {
return ""
}
}
private renderManyToMany(domainClass, property) {
return ""
}
private renderOneToMany(domainClass, property) {
def sw = new StringWriter()
def pw = new PrintWriter(sw)
pw.println()
pw.println "
"
pw.println ""
pw.println " - \${${property.name[0]}?.encodeAsHTML()}
"
pw.println ""
pw.println "
"
pw.println "\${message(code: 'default.add.label', args: [message(code: '${property.referencedDomainClass.propertyName}.label', default: '${property.referencedDomainClass.shortName}')])}"
return sw.toString()
}
private renderNumberEditor(domainClass, property) {
if (!cp) {
if (property.type == Byte.class) {
return ""
}
else {
return ""
}
}
else {
if (cp.range) {
return ""
}
else if (cp.inList) {
return ""
}
else {
return ""
}
}
}
private renderBooleanEditor(domainClass, property) {
if (!cp) {
return ""
}
else {
def sb = new StringBuffer("
sb << "${k}=\"${v}\" "
}
sb << "value=\"\${${domainInstance}?.${property.name}}\" />"
return sb.toString()
}
}
private renderDateEditor(domainClass, property) {
def precision = (property.type == Date.class || property.type == java.sql.Date.class || property.type == Calendar.class) ? "day" : "minute";
if (!cp) {
return ""
}
else {
if (!cp.editable) {
return "\${${domainInstance}?.${property.name}?.toString()}"
}
else {
def sb = new StringBuffer("
sb << "${k}=\"${v}\" "
}
sb << "precision=\"${precision}\" value=\"\${${domainInstance}?.${property.name}}\" ${renderNoSelection(property)} />"
return sb.toString()
}
}
}
private renderSelectTypeEditor(type, domainClass,property) {
if (!cp) {
return ""
}
else {
def sb = new StringBuffer("
sb << "${k}=\"${v}\" "
}
sb << "value=\"\${${domainInstance}?.${property.name}}\" ${renderNoSelection(property)} />"
return sb.toString()
}
}
private renderNoSelection(property) {
if (property.optional) {
if (property.manyToOne || property.oneToOne) {
return "noSelection=\"['null': '']\""
}
else {
return "noSelection=\"['': '']\""
}
}
return ""
}
%>