The internal if/else tags that come with Grails translate directly into if(..) {} else {} at the syntax level to improve performance of such core tags . But you can quite easily write if/else tags using the pageScope object and Grails' standard tags for example: d ...
2008-06-15

Calling static methods on metaclass

关键字: grails, groovy
1、MyClass with a static method class MyClass { static processList(list) { // does something } }   2、Calling static method processList doProcessList(String className, list) { MetaClass mc = ...
import org.codehaus.groovy.grails.commons.ApplicationHolder class BootStrap {     def init = {servletContext ->         ApplicationHolder.application.domainClasses.each() {             ...
默认自动建立名称为HIBERNATE_SEQUENCE的sequence,可以在domain里用以下方法指定:       static mapping = {         id generator: 'sequence', params: [sequence: 'seq_name']     }
import org.codehaus.groovy.grails.commons.ApplicationAttributes def ctx = servletContext.getAttribute(ApplicationAttributes.APPLICATION_CONTEXT)   http://www.nabble.com/Bootstrap-and-applicationContext-td16302106.html#a16302106
2008-06-12

Groovy字符串替换一例

关键字: grails, groovy
将param替换成paramValue   def queryContent = "select * from query where id=${param}" def regex = '\\$\\{param\\}' def matcher = (queryContent =~ /${regex}/) queryContent = matcher.replaceAll('paramValue')   参考: http://docs.codehaus.org/display/GROOVY/Tutorial+5+-+Capturing+r ...
2008-06-10

GORM many-to-many namimg convention

关键字: grails, groovy
I have class named User and another one named Role and they are related to each other in a many-to-many way, a user has many roles and in a role there are many users Besides the user and role tables I get another table named role_user which has only two fields: roles_id and use ...
1、sql.rows returns a List of g.sql.GroovyRowResult which implements Map def results = [] sql.rows(queryString, args).each {Map row -> println "row.dump():${row.dump()}" results << row }  2、sql. eachRow iterates providing a g. ...
2008-05-26

The main advantage of using the Spring DSL

关键字: grails, spring, dsl
The main advantage of using the Spring DSL is that you can now mix logic in within your bean definitions, for example based on the environment : import grails.util.* beans { switch(GrailsUtil.environment) { case "production": myBean(my.company.MyBeanImpl) { bookService = ...
2008-05-26

Configure a bean with map property

关键字: spring, grails
1、Using XML <bean id="sqlService" class="SqlService"> <property name="dataSourceMap"> <map> <entry key="a"> <ref bean="dataSourceA"/> </entry> <entry key=&quo ...