1 2 3 4 5 6 7 8 | excludedProps = ['version', 'id', 'dateCreated', 'lastUpdated', Events.ONLOAD_EVENT, Events.BEFORE_DELETE_EVENT, Events.BEFORE_INSERT_EVENT, Events.BEFORE_UPDATE_EVENT] |
1 2 3 4 5 6 | def list = { if(!params.max) params.max = 10 if(!params.sort) params.sort = "lastUpdated" if(!params.order) params.order = "desc" [ entryList: Entry.list( params ) ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | class Entry { static constraints = { title() summary(maxSize:1000) dateCreated() lastUpdated() } static mapping = { sort "lastUpdated":"desc" } String title String summary Date dateCreated Date lastUpdated } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import grails.util.GrailsUtil class BootStrap { def init = { servletContext -> switch(GrailsUtil.environment){ case "development": new Entry( title:"Grails 1.1 beta is out", summary:"Check out the new features").save() new Entry( title:"Just Released - Groovy 1.6 beta 2", summary:"It is looking good.").save() break case "production": break } } def destroy = { } } |
1 2 3 4 5 6 7 8 9 | <div class="list"> <g:each in="${entryInstanceList}" status="i" var="entryInstance"> <div class="entry"> <span class="entry-date">${entryInstance.lastUpdated}</span> <h2><g:link action="show" id="${entryInstance.id}">${entryInstance.title}</g:link></h2> <p>${entryInstance.summary}</p> </div> </g:each> </div> |
1 2 3 4 5 6 7 8 | /* Blogito customizations */ .entry { padding-bottom: 2em; } .entry-date { color: #999; } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |