grails

How to parse, persist and retrieve a string with tags separated by spaces?

My database consists of 3 tables (one for storing all items, one for the tags, and one for the relation between the two): Table: Post Columns: PostID, Name, Desc Table: Tag Columns: TagID, Name Table: PostTag Columns: PostID, TagID What is the best way to save a space separated string (e.g. "smart funny wonderful") into the 3 databas...

Best free resources to learn Groovy/Grails

What are the best free resources that I can give someone to learn Groovy/Grails? Blogs, tutorials, sample code, sample apps, or presentations would all be helpful. ...

Hibernate Criteria Question

I'm working on a Grails project using Hibernate (GORM). I have the following Domain Models ClientContact{ static hasMany = [owners: Person] static belongsTo = [Person] } Person{ static hasMany = [clientContacts:ClientContact] } When I try to retrieve all the ClientContacts with a specific owner (Person), I'm running into...

How to display image in grails GSP?

I'm still learning Grails and seem to have hit a stumbling block. Here are the 2 domain classes: class Photo { byte[] file static belongsTo = Profile } class Profile { String fullName Set photos static hasMany = [photos:Photo] } The relevant controller snippet: class PhotoController { ..... def vie...

Doing a generic <sql:query> in Grails

This is a generic way to select data from a table and show the results in an HTML table using JSP taglibs. What is the generic way to do this in Grails? That is, take a few lines of SQL and generate an HTML table from scratch in Grails, including the column names as headers. <sql:query var="results" dataSource="${dsource}"> selec...

Are there good Grails sample applications from which to learn?

Besides the sample applications featured in the books Beginning Groovy and Grails and The Definitive Guide to Grails, are there any applications out there written in Grails that are good examples from which to learn best practices? Such as real applications that are open-source? Thanks. ...

How to work around a potential performance issue when using a Grails hasMany relation?

Given the following domain classes: class Post { SortedSet tags static hasMany = [tags:Tag] } class Tag { static belongsTo = Post static hasMany = [posts:Post] } From my understanding so far, using a hasMany will result in hibernate SET mapping. However, in order to maintain uniqueness/order, Hibernate needs to load t...

Add Java Libraries to a Groovy on Grails Project.

I am just getting started with Groovy on Grails. How do I add Java libraries to my Grails project? I added the Smack library jar to the lib folder of my Grails project, but I still cannot import any of its packages into my Java or Groovy classes. I am using the Netbeans IDE. Any help would be appreciated.. Buzzy ...

Changing the database at runtime in Grails application

I am wondering if there is a way to change the database at runtime in grails - e.g., in most commercial/opensource CMS, they allow the database server to be hosted elsewhere, and you can specify the address in some config screen at runtime. since grails configs the database server using DataSource.groovy, how does one access the intern...

Why does automatic injection of log-object not always work in grails?

In the grails-framework some objects are using log. This is normally injected by grails. It works on execution of 'grails test-app'. But the same test (an integration-test) fails on execution of 'grails test-app -integration'. What goes wrong here and can I force the injection of the log-object somehow? ...

integrating Grails and GWT

Hi, GWT seems like a really nice technology for Java developers who don't like (or don't know) HTML/JS/CSS to build rich web interfaces. On the server-side Grails also looks really nice, it's often described as "Rails for Java developers". I've read that Grails' "convention over configuration" approach, together with the benefits of dyn...

How to use Grails j2d plugin to scale an image

I'm using grails j2d which in turns uses GraphicsBuilder to make a simple service to scale an image. My problem is specifically accessing the downloaded image height and width attributes in order to pass the correct parameters to the scale method. How do I access these attributes inside the transformations closure? Controller{ def sca...

How to order by more than one field in Grails?

Is there a way to get a list ordered by two fields, say last and first names? I know .listOrderByLastAndFirst and .list(sort:'last, first') won't work. ...

Grails forwarding and/or redirection with parameters

Is it possible to do page forwarding in Grails? I searched but no luck. If possible, how do I pass parameters in the forwarding method? If not, how would I do it using redirection? I've found something like this for redirection so far: <% response.setStatus(301); response.setHeader( "Location", "http://wodaklab.org/resource/paramName" )...

What are some good resources for learning Grails?

I am planning to learn Grails. Which is the best book that I should refer for this? Is there any website available on this for beginners? ...

SQl Query to Hibernate Query

I have a MYSQL query that I use to retrieve random rows from a table. The query is : SELECT * FROM QUESTION WHERE TESTID=1 ORDER BY RAND() LIMIT 10; Now I need to change this query to Hibernate. Did a bit of Googling but couldn't find the answer. Can someone provide help on this. Thanks ...

Are there any good tutorials for using sitemesh in a grails application?

I'm a pretty experienced Grails developer, but most of my experience has been with using grails for serving up JSON/XML to a flex app and some relatively simple HTML websites. I've been diving deeper into using the sitemesh integration in grails and I'm struggling a little to find best practices for some more complex configurations, and...

Null Pointer when populating Grails Domain object with Oracle 10g long field

We are trying to populate a domain object from an oracle 10g database. The field in question is defined as a string in the domain object with the following constraints. zdata(blank:false,maxSize:3000000) The size of the data is approximately 70K of XML. The table definition looks like this: ZDATA NOT NULL ...

MappedSuperclass Alternatives in Grails

In many past projects, I used this JPA / Hibernate approach to add auditing capabilities to a system. It's very effective and unobtrusive. Is there a Grails @MappedSuperclass alternative (short of coding domain model objects in Java instead of Groovy)? How can one declare a parent class in a table-per-subclass approach without having a ...

Convert datetime in to date

How do I convert a datetime field in Grails to just date, with out capturing the time? I need to do this for comparison with system date. class Trip { String name String city Date startDate Date endDate String purpose String notes static constraints = { name(maxLength: 50, blank: false) st...