<% 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) out << renderDateEditor(domainClass,property) else if(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) { if(property.isEnum()) { 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) { def sb = new StringBuffer('" sb << '' return sb.toString() } 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) { def sw = new StringWriter() def pw = new PrintWriter(sw) pw.println "" return sw.toString() } private renderOneToMany(domainClass,property) { def sw = new StringWriter() def pw = new PrintWriter(sw) pw.println() pw.println "" pw.println "Add ${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) { def sb = new StringBuffer('" sb << '' return sb.toString() } else { return "" } } } private renderBooleanEditor(domainClass,property) { if(!cp) { return "" } else { def buf = new StringBuffer(' buf << "${k}=\"${v}\" " } buf << '>' return buf.toString() } } private renderDateEditor(domainClass,property) { if(!cp) { return "" } else { if(!cp.editable) { return "\${${domainInstance}?.${property.name}?.toString()}" } else { def buf = new StringBuffer(' buf << "${k}=\"${v}\" " } buf << "name=\"${property.name}\" value=\"\${${domainInstance}?.${property.name}}\" ${renderNoSelection(property)}>" return buf.toString() } } } private renderSelectTypeEditor(type,domainClass,property) { if(!cp) { return "" } else { def buf = new StringBuffer(" buf << "${k}=\"${v}\" " } buf << "name=\"${property.name}\" value=\"\${${domainInstance}?.${property.name}}\" ${renderNoSelection(property)}>" return buf.toString() } } private renderNoSelection(property) { if(property.optional) { if(property.manyToOne || property.oneToOne) { return "noSelection=\"['null':'']\"" } else { return "noSelection=\"['':'']\"" } } return "" } %>