- Timestamp:
- Feb 10, 2010, 2:49:13 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/Asset.groovy
r329 r343 26 26 } 27 27 28 // This additional setter is used to convert the checkBoxList string 28 // This additional setter is used to convert the checkBoxList string or string array 29 29 // of ids selected to the corresponding domain objects. 30 30 public void setAssetSubItemsFromCheckBoxList(ids) { 31 31 def idList = [] 32 ids.each() { 33 if(it.isInteger()) 34 idList << it.toInteger() 32 if(ids instanceof String) { 33 if(ids.isInteger()) 34 idList << ids.toInteger() 35 } 36 else { 37 ids.each() { 38 if(it.isInteger()) 39 idList << it.toInteger() 40 } 35 41 } 36 42 this.assetSubItems = idList.collect { AssetSubItem.get( it ) } -
trunk/grails-app/domain/Person.groovy
r294 r343 55 55 String toString() {"${this.firstName} ${this.lastName}"} 56 56 57 // This additional setter is used to convert the checkBoxList string 57 // This additional setter is used to convert the checkBoxList string or string array 58 58 // of ids selected to the corresponding domain objects. 59 59 public void setPersonGroupsFromCheckBoxList(ids) { 60 60 def idList = [] 61 ids.each() { 62 if(it.isInteger()) 63 idList << it.toInteger() 61 if(ids instanceof String) { 62 if(ids.isInteger()) 63 idList << ids.toInteger() 64 } 65 else { 66 ids.each() { 67 if(it.isInteger()) 68 idList << it.toInteger() 69 } 64 70 } 65 71 this.personGroups = idList.collect { PersonGroup.get( it ) } -
trunk/grails-app/taglib/CustomTagLib.groovy
r303 r343 16 16 * To map the selected ids to corresponding domain objects, 17 17 * an additional set method is required in the containing domain class: 18 * // This additional setter is used to convert the checkBoxList string 18 * // This additional setter is used to convert the checkBoxList string or string array 19 19 * // of ids selected to the corresponding domain objects. 20 20 * public void setAssetSubItemsFromCheckBoxList(ids) { 21 21 * def idList = [] 22 * ids.each() { 23 * if(it.isInteger()) 24 * idList << it.toInteger() 22 * if(ids instanceof String) { 23 * if(ids.isInteger()) 24 * idList << ids.toInteger() 25 * } 26 * else { 27 * ids.each() { 28 * if(it.isInteger()) 29 * idList << it.toInteger() 30 * } 25 31 * } 26 32 * this.assetSubItems = idList.collect { AssetSubItem.get( it ) } … … 35 41 * value - the current value. 36 42 * optionKey - the key to use. 37 * displayFields - (optional) available options are 'id' and 'name', defaults to the objects toString(). 43 * sortBy - (optional) the attribute to sort the from list by. 44 * displayFields - (optional) defaults to the objects toString() 45 * displayFieldsSeparator - (optional) defaults to a space. 38 46 * linkController - (optional, requires linkAction.) the controller to use for a link to the objects in the checkBoxList. 39 47 * linkAction - (optional, requires linkController.) the action to use for a link to the objects in the checkBoxList. … … 45 53 * value="${assetInstance?.assetSubItems.collect{it.id}}" 46 54 * optionKey="id" 55 * sortBy="description" 47 56 * displayFields="['id', 'name']" 57 * displayFieldsSeparator=', ' 48 58 * linkController="assetSubItemDetailed" 49 59 * linkAction="show"/> … … 59 69 def isChecked, ht, wd, style, html 60 70 71 def sortBy = attrs.sortBy 61 72 def displayFields = attrs.displayFields 73 def displayFieldsSeparator = attrs.displayFieldsSeparator ?: ' ' 62 74 def linkController = attrs.linkController 63 75 def linkAction = attrs.linkAction … … 81 93 out << html 82 94 95 if(sortBy) 96 from.sort { p1, p2 -> p1[sortBy].compareToIgnoreCase(p2[sortBy]) } 97 83 98 from.each { obj -> 84 99 85 100 displayValue = " " 86 101 87 if( displayFields?.contains("id") )88 displayValue += obj.id + " - "89 90 102 if(linkController && linkAction) 91 103 displayValue += "<a href=\"${createLink(controller: linkController, action: linkAction, id: obj.id).encodeAsHTML()}\">" 92 104 93 if(displayFields ?.contains("name")) {94 displayValue += obj.name105 if(displayFields) { 106 displayValue += displayFields.collect { obj[it] }.join(displayFieldsSeparator) 95 107 } 96 else displayValue += obj 108 else displayValue += obj // use the obj's default toString() 97 109 98 110 if(linkController && linkAction) 99 displayValue += '</a>'111 displayValue += "</a>" 100 112 101 113 // if we wanted to select the checkbox using a click anywhere on the label (also hover effect)
Note: See TracChangeset
for help on using the changeset viewer.