grails

Best Practice: SQL Scripting or Trusting GORM

I have always scripted all DB changes. But I'm wondering if I really need to do that with Grails applications, since GORM will make the changes automatically. So what's the best practice for managing database changes in a Grails application? ...

logging specific package's messages to one file in grails and log4j

trying to get all of the log statements from class GetThatDataFilters to go to the rolling file 'dailydata' and everything else to the console and the daily rolling file. dont know if I am missing something from the grails documentation http://www.grails.org/doc/latest/guide/3.%20Configuration.html#3.1.2%20Logging // ==================...

Grails - check if item has parent

I'm new to Grails, Groovy and GSP. I have a domain class "ProductCategory". class ProductCategory { static constraints = { } static mapping = { table 'product_category'; version false; cache usage: 'read-only'; columns { parent column: 'parentid'; procedure column: '...

login automatically with Grails & Acegi

Hi, I'm using the Acegi plugin in my Grails app. After a user registers, he is redirected to an action that is protected. Therefore, he is shown the login form. However, I would prefer if the user was automatically logged in as soon as he completes registration. It seems like I could achieve this by redirecting to the action that the l...

How do I initialise a Date field in a Grails domain object to act as a timestamp?

I have a domain class which has two dates in it and I want one of them populated with the current time when a record is created for the object, like a create timestamp... class Contact { Date initiatedDate Date acceptedDate } Is it sufficient just to new a Date object on one of them and make the other nullable until such a tim...

Grails limit database column size

Hi, In my Grails app I have a domain class that has a property SearchPrivacy searchPrivacy = SearchPrivacy.PUBLIC where SearchPrivacy is an enum enum SearchPrivacy { PRIVATE('pr'), PUBLIC('pu'); final String id SearchPrivacy(String id) { this.id = id } static getEnumFromId(String id) { values()...

Is this a valid use of Grails transients?

I have a domain object on which I want to store a few things which only exist at runtime. I looked at the documentation and found the transients keyword, which, on the face of it was what I was looking for. Here is what my domain object looks like... class Contact { def Seeker def beforeInsert() { initiatedDate =...

grails-ui plugin autocomplete component error

I'm programming a page that uses the grails-ui plugin "autocomplete" feature. It doesn't work and the error console shows the error "YAHOO is not defined"; searching the web I tried the following: Install the yui2 ad 3 plugins Uninstall the grails-ui plugin reinstall the grails-ui plugin With no luck. Any ideas ? I'm using grails 1....

Grails: adding dynamic methods within a plugin

Hi, I'm developing a plugin that adds a getFlashHelper method to each controller. This method should return an instance of a FlashHelper class. However, the constructor of the FlashHelper class must be passed the instance of the controller on which the getFlashHelper method was called. Hopefully the following code will explain what I'...

Deployment issues on Tomcat

I am unable to deploy grails war in tomcat . Copied all 55 jars to $CATALINA_HOME/shared/lib/grails-jars/ Added shared.loader= ${catalina.home}/shared/lib/grails-jars/*.jar And started tomcat successfully. Now deployed grails war in deploy folder (war is ~572.4KB). The console shows these errors : log4j:ERROR Could not instanti...

Grails with SpringSecurity, local users and LDAP

I use the SpringSecurity-framework for authentication, and it works as long as there is a user with the same name in my local DB. However, I want an admin-account that is only stored in the local DB and has no equivalent in LDAP. So, how can I configure SpringSecurity so that it uses LDAP and if this fails looks for a user and password...

Using Grails 1.2.0 and Spock 0.4-SNAPSHOT - Compilation errors

Using Grails 1.2.0 and the latest Spock 0.4-SNAPSHOT (as of 01/28/2010 10:18 EST) I'm getting compilation errors that the Groovy compiler is unable to find: org.apache.commons.httpclient.Cookie and org.apache.commons.httpclient.NameValuePair No matter what I've tried (adding it as a dep in the plugin, adding it as a dep in the app) i...

grails plugin reloading

Hi, When developing a Grails plugin, you can configure it to reload using either the watchedResources or observe properties. From my reading of the official docs, it seems that the former will cause the plugin to reload when a file changes, and the latter when a plugin changes, is that correct? Say for example, a plugin needs to reload...

Grails global constraints

Hi, In version 1.2, Grails introduced global constraints. I tried adding the following to Config.groovy grails.gorm.default = { constraints { notBlank(nullable:false, blank:false) } } Then using it in one of my domain classes static constraints = { email(email: true, unique: true, shared: 'notBlank') } But whe...

How To Call A Taglib As A Function In A Domain Class

I need to call the Static Resources Plugin (http://www.grails.org/Static+Resources+Plugin) from my domain class. This works perfectly in a controller: def tstLink = resourceLinkTo(dir:"docs/${identifier}",file:originalFileName) but in a domain class I get Exception Message: No signature of method: static org.maflt.ibidem.Item.resou...

Temporary uploaded file location in grails

I'm about to program a file upload in a Grails app - using g:form with *"multipart/form-data"*. Before saving it to disk, I'll check if the file is bigger than a given number of bytes, in which situation it will be discarded. My concern is: is the temporary file stored in some directory before it is moved to the final destination ? Becau...

Grails acegi plugin user recommendation

I'm about to add security to my Grails App, and I'd like to know from your experiences what's the best approach: To add fields to the Person Domain class (such as phone, address, etc.) To create an independent Domain class and map it one to one to the Person class ...

MVC in Groovy/Grails

Hi, I'm newbie to groovy. How can we call domain methods from controller in Grails. Controller : def results = User.fetch_results User Domain : def fetch_results { def users = this.get(1) } Sorry if the above code is wrong, i need to know how to access domain methods from controller. thanks. ...

How do I check in files for building with git?

I'm using git to manage a grails project I have.I set up a git repository on a remote server and what I want to do is when I have code working locally, I want to commit it and push to the remote server. I want the updated groovy file and gsp's to be put into the right spot on the remote server so that grails will pick up the changes for ...

Multiple grails applications on Tomcat

I'm about to deploy several grails apps on top of a single Tomcat server, and I have the following doubts: In terms of memory usage: Does it make a difference to put the common grails libs under shared/lib instead of putting them in each app's war files? Is there a list of those jars ? If so, is there a mechanism not to package those j...