grails

SQL/Database Views in Grails

Does anybody know what is the best approach to accessing a sql view through Grails (or if this is even possible)? It seems an obvious way of doing this would be to use executeQuery against the view to select a collection of rows from the view which we would not treat as a list of domain objects. However, even in this case it is not obvio...

Groovy Mixins?

I'm trying to mix-in a class in my Groovy/Grails app, and I'm using the syntax defined in the docs, but I keep getting an error. I have a domain class that looks like this: class Person { mixin(ImagesMixin) // ... } It compiles fine, but for some reason it won't work. The file containing ImagesMixin is located in my /src/groovy/...

Executing groovy statements in JavaScript sources in Grails

There are essentially 2 places to define JavaScript functions in Grails, directly in a element on the GSP, and within a separate javascript source file under /web-app/js (for example, application.js). We have defined a commonly reused javascript function within application.js, but we also need to be able to generate parts of the functio...

Grails Domain Class without ID field or with partially NULL composite field

Per an answer to a previous question (answer here: http://stackoverflow.com/questions/425294/sql-database-views-in-grails#427691), I have tried to use a domain class to represent a view in my database. This works wonderfully in most cases, however: I have a view with no single unique key. Let's say the underlying tables look like this: ...

Grails, Inserting lots of data using withTransaction results in OutOfMemoryError

I'm using Grails 1.1 beta2. I need to import a large amount of data into my Grails application. If I repeatedly instantiate a grails domain class and then save it, the performance is unacceptably slow. Take for example importing people from a phone book: for (each person in legacy phone book) { // Construct new Grails domain class f...

Grails domain class, String field TEXT and LONGTEXT

In a Grails domain class, how do I set the constraint for a String field so that its MySQL column type is TEXT or LONGTEXT? So far my best approach is to set the constraint's size: myTextField(size:0..65535) which results in TEXT myTextField(size:0..2147483646) results in LONGTEXT (2147483646 = 2^32 / 2 - 1 - 1) Is there a clean...

making download option in grails

I am in the training of web developement.I want make a page which shows all the files in the D://downloads directory.I made that part in grails.If i click on the particular file i want download that file.I dont know how to make that part.I did a google search.But i cannot do that. My code is <g:each in="${fileList}" var="filename" st...

How can fields in Grails represented by a combobox be made optional?

I'm doing my first experiments with Grails and am looking for a way to have fields represented by a combobox (such as one-to-one domain associations and numbers with a narrow range constraint) to be optional, i.e. there should be an empty entry in the combobox. How can this be achieved? I've tried both adding a nullable:true constraint ...

RESTful Grails: how do I include related entities in my XML?

Let's say I have a class called Store that has many Employees. My RESTful listXML method looks like this: def listXML = { render Store.list() as XML } And the result looks like this: <stores> <store id="1"> <name>My Store</name> <employees> <employee id="1" /> </employees> </store> </store> My question is, how...

Documenting taglibs (or closures in general) in Groovy/Grails

I am writing my first taglib as part of a plugin and I would like to document it. Adding javadoc (is there any place that documents groovydoc or is it really the same thing?) doesn't seem to work for non-methods. Specifically, is it possible to document the def mytag in: /** * This doc shows up */ class MyTagLib { static namespace ...

How to count in Grails/Hibernate: Message.countBy

How do I count the number of messages where my body length is between 0 and 25 characters long? Message.countBy('from Message m where m.body.length <= 25') Unfortunately for me, countBy does not take a string parameter. ...

Suggestions for Grails .gitignore

So far i've collected the following: *.iws *.war .classpath .DS_Store .project .settings /*.launch /*.tmproj /out/** stacktrace.log test/reports Any other suggestions? ...

Intellij IDEA setup on OS X

What's the accepted procedure and paths to configure jdk and global library source code for Intellij IDEA on OS X? ...

How to determine if a given URL link is a video or image?

I'm trying to take a given URL entered by user and determine if the URL is pointing to a image or a video. Example use case. When a user paste in the URL of a youtube video, on save the page will auto display the embedded Youtube player. When a user poaste int he URL of a picture in flickr, on save, the page will auto display a small...

Grails Error for using e-mail service

This is the controller class JavaMailerController { JavaMailerService javamailerservice def x = {javamailerservice.serviceMethod()} } This is the Service import javax.mail.; import javax.mail.internet.; import java.util.*; class JavaMailerService { boolean transactional = false def serviceMethod() { String d_ema...

UTF-8 only in Grails database tables

When using Grails 1.0.4 together with a MySQL the charsets of the auto-generated database tables seem to default to ISO-8859-1. I'd rather have everything stored as pure UTF-8. Is that possible? From the auto-generated database definitions: ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; Note the "latin1" part. ...

Controllers in Grails

I'm writing a small webapp in Grails and I have the following question regarding best practices for controller design and using GORM: I'm storing the user object in session.user. Currently all my action methods start with the following code to make sure a valid user is logged in and that the user object is fresh: class FooController { ...

GORM in Grails and StaleObjectStateException

I'm writing a small Grails app, and I keep on getting StaleObjectStateException:s for about 1/10:th of the calls to "createfoo" when running the following rather simple code. Most probably I'm missing out on the best way to use GORM. This is the code: def viewfoo = { session.user.refresh() // ... } def createfoo = { session.user...

Is it possible to work with GSP (groovy server pages) without the whole grails stuff?

I'd just like to play a little bit with groovy I was thinking about developing my own-tiny web framework, something very simple and manageable... So i'd like tou use GSP pages whtout having to install the whole grails stuff, with all its dependencies and behind-the-scenes frameworks... can anyone provide me detailed instructions on wh...

How to find the physical path of a GSP file in a deployed grails application

I need to find out the physical path of a grails GSP file. My requirement is that I want to create a new layout file at run-time and use that in the application. I have been able to achieve this without problem when the application runs on jetty (grails run-app), however, when I deploy the app on Jboss, the path at which the file nee...