grails

Grails database migration on deployed server

半城伤御伤魂 提交于 2020-01-13 11:39:29
问题 Hi everyone I am encountering a problem/confusion with grails database migration plugin. Resources used for studying- Official Grails Database Migration Plugin documentation- http://grails-plugins.github.io/grails-database-migration/docs/manual/guide/introduction.html Database migration example- http://grails.github.io/grails-howtos/en/manageDatabases.html Now with the help of these I am very well able to migrate or do changes to my database on the local machine which has grails installed and

How to specify default transaction isolation level in Grails

扶醉桌前 提交于 2020-01-13 10:16:09
问题 I cannot figure out how to specify default transaction isolation level in Grails application . Please help and point where my mistake is. Following are the details. Grails: 1.3.7 Database: Sql Server 2008. DataSource.groovy: dataSource { ... driverClassName = "net.sourceforge.jtds.jdbc.Driver" dialect = org.hibernate.dialect.SQLServerDialect defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED } hibernate { ... connection.isolation = java.sql.Connection.TRANSACTION

Grails Detect if a Plugin is Installed

…衆ロ難τιáo~ 提交于 2020-01-13 08:49:07
问题 Is there a way in Grails to Detect that a plugin is installed. For example I need to know if the "Acegi" plugin is installed. If it is then I can run different Code. If the plugin is not installed (which is a viable option) then I can run different code. Thanks in Advance. 回答1: You can use the plugin manager for this: import org.codehaus.groovy.grails.plugins.PluginManagerHolder if (PluginManagerHolder.pluginManager.hasGrailsPlugin('acegi')) { ... } 回答2: Update for Grails 2.4+ Note that the

Grails Render Template Different Controller/Path

泪湿孤枕 提交于 2020-01-13 07:44:26
问题 I have a template that exists under views/dashboard/_myTemplate.gsp and from the DashboardController I can simply call render template:'myTemplate' and all is well. I have a need to render this template from a different controller but the render method doesn't allow you to specify a controller and I can't seem to figure out how to define the path at which the template exists for the render to work correctly. Is this even possible? 回答1: You do it by controller name: render(template:'/dashboard

“call 'refresh'” error resulting from Grails WAR hot-deploy

女生的网名这么多〃 提交于 2020-01-13 04:56:12
问题 When my Grails WAR is hot-deployed to Tomcat and I refresh the page, I get this error: 1 Feb, 2010 7:00:51 PM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet view-servlet threw exception java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory

What is an efficient way to create/manage RESTful API with grails?

不问归期 提交于 2020-01-13 03:11:32
问题 I've built my first grails application. My URL mappings are what the default application provides: static mappings = { "/$controller/$action?/$id?"{ constraints { // apply constraints here } } "/"(view:"/index") "500"(view:'/error') } Senario I have a controller called ColorController with actions save and list . It simply does something like this: def save () { def colorInstance = new Color(params) colorInstance.save(flush: true) } def list () { [colorList: Color.list, colorTotal: Color

Read a file form web-app

不想你离开。 提交于 2020-01-12 18:46:35
问题 Inside a grails application, I need to upload a file under web-app/js, add a prefix, and put it in S3. I'm having trouble figuring out how to read the js file in a way that will work in development (/web-app/js) and production (/js). I'm doing this from inside a domain object. 回答1: In your controllers, you can call : def jsFolder = grailsAttributes.getApplicationContext().getResource("js/").getFile() and then proceed with jsFolder . To determine the base directory of a running Grails

Read a file form web-app

♀尐吖头ヾ 提交于 2020-01-12 18:46:03
问题 Inside a grails application, I need to upload a file under web-app/js, add a prefix, and put it in S3. I'm having trouble figuring out how to read the js file in a way that will work in development (/web-app/js) and production (/js). I'm doing this from inside a domain object. 回答1: In your controllers, you can call : def jsFolder = grailsAttributes.getApplicationContext().getResource("js/").getFile() and then proceed with jsFolder . To determine the base directory of a running Grails

Grails Spring-Security -how to compare passwords-

微笑、不失礼 提交于 2020-01-12 16:41:49
问题 Im using SpringSecurity 2.0-RC2 and want users to give the possibilty to change their passwords while they are online. My User domain class has the following def beforeInsert() { encodePassword() } def beforeUpdate() { if (isDirty('password')) { encodePassword() } } protected void encodePassword() { password = springSecurityService.encodePassword(password) } To check whether the user was enterering the correct current password i was doing the following in a controller: if

Groovy GDK equivalent of Apache Commons StringUtils.capitalize(str) or Perl's ucfirst(str)

烂漫一生 提交于 2020-01-12 16:06:13
问题 Yes/no-question: Is there a Groovy GDK function to capitalize the first character of a string? I'm looking for a Groovy equivalent of Perl's ucfirst(..) or Apache Commons StringUtils.capitalize(str) (the latter capitalizes the first letter of all words in the input string). I'm currently coding this by hand using .. str = str[0].toUpperCase() + str[1 .. str.size() - 1] .. which works, but I assume there is a more Groovy way to do it. I'd imagine ucfirst(..) being a more common operation than