grails

Eager Loading with Many-to-Many relationship - Grails (GORM)

Each book can have many authors. And each author can author many books. class Book { static belongsTo = Author static hasMany = [authors:Author] } class Author { static hasMany = [books:Book] } Now when can I do: def book = Book.get(id) def authors = book.authors Now I am thinking I should be able to take each author and ...

How To Determine A Parent Class in Grails

I have a base class that all of my domain classes extend, for example: class Customer extends IbidemBaseDomain { . . } Is there any way within my base class to determine what class is extending it. So in this example, is there anyway for IbidemBaseDomain to know that it's being extended by Customer? ...

Grails and Hibernate's Lazy Initialization Exception

Where are the most common places where you've gotten an org.hibernate.LazyInitializationException in Grails, what was the cause and how did you solve it ? I think this one exception comes up a lot for novice, so if you'd provide more examples, it would be great. ...

Grails request parameter type conversion

Hi, In my Grails app, I need to bind a request parameter to a Date field of a command object. In order to perform the String-to-Date conversion, one needs to register an appropriate PropertyEditor in grails-app\conf\spring\resources.groovy I've added the following bean definiton: import org.springframework.beans.propertyeditors.Custom...

Code re-use between Grails project - keeping it DRY

The Grails framework has a lot of constructs/features that allows for adhering to the DRY principle ("don't repeat yourself") within a project. That is: within a specific project you're seldom required to repeat identical blocks of settings or code. So far so good. However, the more I've worked with Grails the more of I've observed that...

Using Curry to Define Grails Tags

I have a grails tag library TpTagLib and in it I want to define 4 new tags that differ only in one constant value, so I tried to use curry. But there is an exception: groovy.lang.MissingPropertyException: No such property: attr for class: TpTagLib Does anyone have any idea why this exception occurs? Here is the code: def ifPermsTag = ...

Grails - multiple belongsTo of same class with cascading deletion

Hi all, This one is for the Grails users here. I asked it on the grails - user mailing list, but I figured since I've been fighting this for a couple of days I should cast as wide a net as possible. I'm having some difficulty with trying to model relationships between two objects of the same type in another object (different type) ref...

How to setup one-to-many unidirectional mapping for grails application on GAE ?

I try to perform testing on one-to-many unidirectional mapping for grails application on google app engine (GAE) using JPA. The one-to-many unidirectional mapping I attempt to define is between User and Role class. Unfortunately, I am stuck. Just curious is there any developer out there able to make it work successfully. Following is my...

How do I integrate WordPress blogs with my Grails application?

I had my static site with which WordPress blogs were integrated. Now I have made a Grails application with which I want to integrate those WordPress blogs. I had put the WordPress folder copied from my previous site to the web-app folder of my Grails application. But I am not able to access the WordPress folder, as when I hit URL - htt...

Groovy/Grails date class - getting day of month

Currently I'm using the following code to get year, month, day of month, hour and minute in Groovy: Date now = new Date() Integer year = now.year + 1900 Integer month = now.month + 1 Integer day = now.getAt(Calendar.DAY_OF_MONTH) // inconsistent! Integer hour = now.hours Integer minute = now.minutes // Code that uses year, month, day, h...

Groovy domain mapping

Hi! I have a to save a pdf report into an Oracle DB. The report's dataType is a byteArray. The domain definition is as follows: static constraints = { report(nullable:false) company(nullable:false) month(nullable:false) } byte[] report Company company Date month } Unfortunately this defines in the Oracle DB a field whic...

Typemismatch with I18N Label instead of Attribute Name

My message.properties contains this by default: typeMismatch.java.lang.Double=Property {0} must be a valid number Placeholder {0} is replaced by the Attribute Name. I want to use the Label that is used for the frontend like this: typeMismatch.java.lang.Double=Property {wonderful label here} must be a valid number. My first Attempt: ...

Groovy 1.5.x / Grails 1.0.x If-Else statement bug

I have this code in a Grails 1.0.4 Groovy console: def devices = Device.getAll() def found = devices.findAll { if(it?.localNumber && it?.areaCode){ def pattern = ~".*${it.areaCode + it.localNumber}" def matches = "$msisdn" ==~ pattern println "$matches == msisdn: $msisdn ==~ pattern: $pattern" matche...

Getting the URL of the current page in Grails

In a Grails application I'd like to send a user from page A, then to a form on page B and then back to page A again. To keep track of which URL to return to I send a "returnPage" parameter to page B containing the URL of page to return to (page A). Currently I'm using request.getRequestURL() on page A to retrieve the page's URL. Howeve...

Grails GSP doesn't generate intended HTML under Geronimo

When running my Grails 1.1-M2 app as a WAR under Geronimo 2.1.4 (jetty6, javaee5), the HTML generated from the GSPs do not include my dynamic content. Specifically, this GSP snippet: <tr class="prop"> <td valign="top" class="name"> <label for="type"> <g:message code="album.type.label" default="Type" /> <...

Inject log object in Grails class outside of grails-app

I have a class in src/groovy in my grails project. How do i make a log field that gets injected with the correct logger for that class ? Is there a commons logging or just log4j in grails ? ...

Nested GORM embedded

I'm in the process of exporting a Spring (and Hibernate) application to Grails. Using GORM I wanted to do the following: class A { B b static embedded = ['b'] } class B { C c static embedded = ['c'] } class C { } And got: org.hibernate.MappingException: Could not determine type for: C, at table: a, for columns: [or...

Grails: Reuse a predefined list

Hi, I am new to Grails and currently using Grails 1.1.1. I don't know how to pass a list from a control/action to a view and then pass the same list from that view to another action. The reason I do this is to reuse the predefined object (a "list" in this case). Here is my scenario: I have a search view (search.gsp) that calls the "...

war file generated by Grails ignores dataSource URL

Grails version :1.1 Tomcat version: 5.5 The problem: The application doesn't use the URL data sources. It seems like - it is using some other data source- but it doesn't seem to be in memory DB- since I can see the data persisted between sessions. I have even tried giving a non -existant database name -and the application works fine...

Group Controllers to functional Packages in Grails

Im developing a Grails App. I have about 20 Controllers right now and there will be more. Is there a way to Group the Controllers in functional Packages? I would like to have something like: grails-app/administration/<controller classes> grails-app/usercontent/<controller classes> grails-app/publiccontent/<controller classes> The best...