ITeye博客

BoogieEEEEE

boogie · 共 56 篇文章

Reload an IFram with jQuery

Accessing the contentWindow property to obtain the location object. $('#iframe').each(function() { this.contentWindow.location.reload(true); }); Callback for IFrame Loading With the onload event, your code is called when an IFrame has finished loading. $('#iframe').load(function() { // do something…

2008-10-02 09:13 · AJAX · 评论(0)

Reading XML with jQuery

1、sites.xml <?xml version="1.0" encoding="ISO-8859-1"?> <sites> <site id="0"> <title>Think2Loud</title> <url>http://www.think2loud.com</url> <desc> <brief>this is the brief description.</brief> <long>...and this is the long description. See how long it is :)</long> </desc> </site> <site id="2"> <ti…

2008-09-09 11:05 · AJAX · 评论(0)

Property configuration of dataSource

def props = new Properties() InputStream is = new BufferedInputStream(new FileInputStream("${System.getenv("SITEHOME")}/config/cms.properties")) props.load(is) is.close() environments { test { dataSource { dbCreate = "create" // one of 'create', 'create-drop','update' driverClassName = "org.hsqldb.…

2008-07-11 08:42 · Grails · 评论(0)

Writing the <g:if> tag in a tag library

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: def ifSomething = { attrs, body -> p…

2008-06-24 11:51 · Grails · 评论(0)

Calling static methods on metaclass

1、MyClass with a static method class MyClass { static processList(list) { // does something } } 2、 Calling static method processList doProcessList(String className, list) { MetaClass mc = GroovySystem.metaClassRegistry.getMetaClass(Class.forName(className)) mc.invokeStaticMethod(‘processList’, list…

2008-06-15 09:37 · Grails · 评论(0)

List of all domain classes in BootStrap

import org.codehaus.groovy.grails.commons.ApplicationHolder class BootStrap { def init = {servletContext -> ApplicationHolder.application.domainClasses.each() { println it.fullName // full name with package println it.name // simple class name it.metaClass.delete = {-> throw new RuntimeException("D…

2008-06-14 22:02 · Grails · 评论(0)

Grails ORM id generator in Oracle

默认自动建立名称为HIBERNATE_SEQUENCE的sequence,可以在domain里用以下方法指定: static mapping = { id generator: 'sequence', params: [sequence: 'seq_name'] }

2008-06-14 20:18 · Grails · 评论(0)

Get applicationContext in Bootstrap

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-14 20:00 · Grails · 评论(0)

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+regex+groups

2008-06-12 17:11 · Grails · 评论(0)

GORM many-to-many namimg convention

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 users_id roles_id refers…

2008-06-10 11:50 · Grails · 评论(0)

Difference between sql.rows().each and sql.eachRow

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.sql. GroovyResultSet which implements java.sql.ResultSet. ResultSet is n…

2008-06-08 10:20 · Grails · 评论(0)

The main advantage of using the 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 = ref("bookService") } break …

2008-05-26 10:56 · Grails · 评论(0)

Configure a bean with map property

1、Using XML <bean id="sqlService" class="SqlService"> <property name="dataSourceMap"> <map> <entry key="a"> <ref bean="dataSourceA"/> </entry> <entry key="b"> <ref bean="dataSourceB"/> </entry> </map> </property> </bean> 2、Using the Spring DSL beans = { def dsMap = new HashMap() dsMap.put('a', ref(…

2008-05-26 10:33 · Grails · 评论(0)

Configure a bean with factory using Spring DSL

1、How do I configure a bean like this using Spring DSL ? <bean id="mailSession" class="javax.mail.Session" factory-method="getInstance"> <constructor-arg> <props> <prop key="mail.smtp.auth">true</prop> </props> </constructor-arg> <constructor-arg ref="smtpAuthenticator" /> </bean> 2、 To answer my o…

2008-05-22 17:38 · Grails · 评论(0)

Eclipse3.2 (Ubuntu)与Ant出错解决

https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/134537 出错原因: Eclipse 3.2 requires ant 1.6. However, gutsy only includes ant 1.7 解决方法如下: cd /tmp mkdir ant cd ant unzip /usr/share/java/ant-launcher.jar unzip /usr/share/java/ant.jar jar cf ../ant.jar * sudo rm /usr/lib/eclipse/plugins/org.apach…

2008-02-18 23:15 · 评论(0)