grails

Grails: Services VS Groovy classes

Documentation says: The Grails team discourages the embedding of core application logic inside controllers, as it does not promote re-use and a clean separation of concerns. I have one API controller and a few Groovy classes in src/groovy folder. Those classes just implements my application logic so actions in API controll...

Grails Plugins and Team City

This is my current scenario: I have checked in my grails app code + Groovy Folder + Grails Folder using GIT to teamcity. Now when I try to run it Teamcity trows me this error: [13:33:35]: Error reading remote plugin list [java.net.ConnectException: Connection refused: connect], building locally... [13:33:35]: Plugins list cache doesn't...

rendering JSON in GRAILS with part of the attributes of an object

Hello, I am trying to build JSON from two fields. Say, I have a list of object(party), and I only need to pass 2 items as JSON pair. def list = getMyList() //it contains 2 party objects partyTo = array { for (i in list) { x partyId: i.id y partyName: i.toString() } } The JSON string is {"partyTo":[ ...

grails prod run-app connects to mysql but grails prod run-war doesn't

Hi, I have a unexpected problem. I had create a war with grails war. Then I had deployed in Tomcat. For my surprise the crud works fine but I don't know what persistence is using, because it isn't use the mysql database I had configurate. I know that because it doesn't list the data in the database. So I did this test: Compare grail...

Does overloading Grails static 'mapping' property to bolt on database objects violate DRY?

Does Grails static 'mapping' property in Domain classes violate DRY? Let's take a look at the canonical domain class: class Book {      Long id      String title      String isbn      Date published      Author author      static mapping = {             id generator:'hilo', params:[table:'hi_value',column:'n...

How to log sql statements in grails

Hi I want to log in the console or in a file, all the queries that Grails do, to check performance. I had configured this without success. Any idea would help. ...

Grails efficient hasMany-Relationship in View

Hi folks, I'm saving contacts (email, mobile phone, ICQ, AIM etc.) for people like this: class Person { static hasMany = { contacts: Contact } } class Contact { String code ContactType type } class ContactType { String name } In my view, I've written some Templates for displaying each contact with a select-box for the c...

Is there an efficient way to call a Grails template from a string loaded from db?

I store user editable articles in a database. Users can insert some simple widgets into the articles (graphs and so on). So far I've implemented this as a proof of concept by letting the user insert graphs like [graph-1] and than do a string search and replace. I was wondering whether there are more efficient ways of calling templates ...

Read a file form web-app

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. ...

new form in grails portlet

Hi, How to redirect to new different form page in Grails portlets . When click on "New User" it should show new.gsp (here). but this is not happening and always redirects to view.gsp . I'm using like this in view.gsp : a href="${portletResponse.createActionURL()}" name="new_user" id="new_user">New User please suggest me . ...

How can I tell groovy/grails not to try to "re-encode" binary data? (Revised title)

I have a groovy/grails application that needs to serve images It works fine on my dev box, the image is returned properly. Here's the start of the returned JPEG, as seen by od -cx 0000000 377 330 377 340 \0 020 J F I F \0 001 001 001 001 , d8ff e0ff 1000 464a 4649 0100 0101 2c01 but on t...

How can i use 'log' inside a src/groovy/ class

I'm encountering this error: groovy.lang.MissingPropertyException: No such property: log for class: org.utils.MyClass Here's the content of the class: package org.utils class MyClass { int organizationCount = 0 public int getOrganizationCount(){ log.debug "There are ${organizationCount} organization(s) found....

Convert grails app to plugin

Hello, I started a grails application by grails create-app. For modularity, I feel like it would be better that component be a plugin. Can I convert this application into a grails plugin? thanks, Babu. ...

how do i set up a grails environment variable

I'm uploading images in a grails app I'm developing and I want to be able to have an environment variable the determines where these images are. So if I'm working locally it can just pull from /home/MyName/images but once it's in production it will pull from http://images.site.com. How would I do that? I'm assuming i can set up my config...

Gorm findallby date tip

Hi, any quick tip to implement findAllByGreaterThan so I can filter those records which date field is today (from 00:00 up to present). Thanks in advance ...

Best practices for using Hg with Grails?

What should I check in/not check in? Since many of the files are sometimes auto-generated I'm not entirely sure how to handle this using version control...does it have something to do with tags? For instance in ANT, I know not to check-in my target/bin directories...but Grails adds another level of confusion to this...since some of cod...

Multiple dynamic method calls or declaring a variable in Grails

In my view, if I have a situation where I need to use a dynamic method (such as Domain.findByName("name")) in multiple places, would it be better to define a variable with and refer to that, rather than have the dynamic method in multiple places? I know this seems like an obvious answer, but I just wanted to make sure Grails doesn't cac...

converting html entity to utf-8 character

Hello, I am having this problems in grails where I am writing a string from the database into an xml file using StreamingMarkUpBuilder. The xml file displays the string as htmlentities &#x30b3 &#x30d4 &#x30fc, how can I convert them to be printed as コピー? Thanks! ...

Is it possible for a Grails Domain to have no 'id'?

Is it possible to create a table that has no 'id'? For example, this is my domain: class SnbrActVector { int nid String term double weight static mapping = { version false id generator: 'identity' } static constraints = { } } When I run this SQL statement, it fails: insert into snbr_act_...

Sort by association count in Grails

I have many Topic objects and each Topic hasMany posts:Post How can I order all Topic objects based on their posts count?? ...