Changeset 286 for trunk/grails-app


Ignore:
Timestamp:
Jan 21, 2010, 4:07:26 PM (14 years ago)
Author:
gav
Message:

Add CustomTagLib with checkBoxList.

Location:
trunk/grails-app
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/AssetDetailedController.groovy

    r284 r286  
    218218                }
    219219            }
     220
    220221            assetInstance.properties = params
     222
     223            assetInstance.setAssetSubItemsFromCheckBoxList(params.assetSubItems)
     224
    221225            if(!assetInstance.hasErrors() && assetInstance.save(flush: true)) {
    222226                flash.message = "Asset ${params.id} updated"
  • trunk/grails-app/domain/Asset.groovy

    r268 r286  
    2323        "${this.name}"
    2424    }
     25
     26    //  This additional setter is used to convert the checkBoxList string
     27    //  of ids selected to the corresponding domain objects.
     28    public void setAssetSubItemsFromCheckBoxList(ids) {
     29        def idList = []
     30        ids.each() {
     31            if(it.isInteger())
     32                idList << it.toInteger()
     33        }
     34        this.assetSubItems = idList.collect { AssetSubItem.get( it ) }
     35    }
     36
    2537}
    2638
  • trunk/grails-app/taglib/AssetTreeTagLib.groovy

    r285 r286  
    1 
     1/**
     2* Asset Tree tags.
     3* Specific to gnumims hence the namespace.
     4*/
    25class AssetTreeTagLib {
    36    static namespace = 'gnumims'
  • trunk/grails-app/views/assetDetailed/edit.gsp

    r276 r286  
    8585                                </td>
    8686                                <td valign="top" class="value ${hasErrors(bean:assetInstance,field:'assetSubItems','errors')}">
    87                                    
    88                                     <g:select name="assetSubItems"
    89                                                     from="${AssetSubItem.list()}"
    90                                                     size="5" multiple="yes" optionKey="id"
    91                                                     value="${assetInstance?.assetSubItems}" />
     87                                    <custom:checkBoxList name="assetSubItems"
     88                                                                    from="${AssetSubItem.list()}"
     89                                                                    value="${assetInstance?.assetSubItems.collect{it.id}}"
     90                                                                    optionKey="id"/>
    9291
    9392                                </td>
Note: See TracChangeset for help on using the changeset viewer.