grails

Can grails models be used by a standalone java app?

Hi, i'm writing code from scratch. The 2 components of the system will be a std web-site, plus a game server written in java. The shared objects between the 2 components will be the models. What i'd like to do is create the models in grails and then have the java game-server code use these models, as well as have the grails code use the...

How to force grails to download csv files ?

In my gsp view, I have this code : <g:each in="${fileResourceInstanceList}" status="i" var="fileResourceInstance"> <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> <td>${fileResourceInstance.decodeURL()}</td> <td><a href="${createLinkTo( dir:"/upload_data/datasets/ds"+signalDataInstance.datasetID , file: fileResourceInstance.decodeURL(),...

Is it worth having static resources in a separate domain/server?

I am currently in the process of improving my grails website performance and following many best practices I found on the internet, I currently need to make a decision between two solutions before refactoring my code Solution 1 : Export all of my static resources (js, css, images) to a separate domain and server (as already done by SO ...

Interrupting grails dynamic methods

Hi I have one grails application.In that I have one model class named Book. From any controller if I am calling Book.list(), Book.get(id) and some other hibernate calls like save() I want to authorize using current login user role. If authorization fails i have to throw some error. Is there any plugin available for this. Please give me...

Grails with SpringSecurity, check if the current user can access controller / action

Hi, I'm currently developing a menu for my application that should be able to display only the controllers that the current user can access (requestmap defined in the database). How can I check if the current user has access to a specific controller and action? Thanks, Jan ...

Using authsmtp from a Grails server

This is quite a specific question, and I have had no luck on the grails nabble forum, so I thought I would post here. I am using the grails mail plug-in, but I think my question is a general one about using authsmtp as an email gateway from my server. I am having trouble sending mail from my app using authsmtp. I have installed and co...

Get Spring Security intercept urls from database or properties

Hopefully this is super simple, exists, and I'm overlooking something right under my nose. I know that I can restrict access via annotations: @Secured({"ROLE_ADMIN"}) or via config: <security:intercept-url pattern="/**" access="ROLE_USER, ROLE_ADMIN, ROLE_SUPER_USER" /> I would prefer to obtain authentication rules from a database...

How to resolve having 2 belongsTo in a single domain

I have the following domains: User, Role, Company. User and Role has m:n relationship, Company to User has 1:m, and User to Company is 1:1. I'm having problem with the definition of User domain. Here it is: class User { static hasMany = [authorities: Role ] static belongsTo = [ Role , Company ] } I would like to access the company f...

Grails: org.hibernate.TransientObjectException

Simple Groovy\Grails code: def start = { source.save() def result = getJson(hotelSite, eng + index, [:]) parse(JSONObject.fromObject( result.json.text() )) render "OK" } def parse = {JSONObject json -> def cities = json.get("filter").cities println cities def kievHotels...

How to change Glassfish's default error page?

Hi, I'm writing Grails application, that sometimes responds with 422 http status code (on invalid AJAX calls). While deployed on Glassfish, container includes default error page after my view's rendered text. How to change this behaviour? Regards, Tarmo ...

Best strategy to initially populate a Grails database backend

Hi, I'd like to know your approach/experiences when it's time to initially populate the Grails DB that will hold your app data. Assuming you have CSVs with data, is is "safer" to create a script (with whatever tool fits you) that: 1.-Generates the Bootstrap commands with the domain classes, run it in test or dev environment and then use...

Groovy/Grails plugin for Sonar

Sonar is an application for integrating output from several static and test analysis tools into a comprehensive overview of the software's quality. Unfortunately, most of those analysis tools (PDM, FindBugs, etc.) do not support Groovy and, by extension, Grails. We've found tools called CodeNarc and GMetrics which perform some of the a...

How to execute a service once the Grails Server is ready

I have a Grails application which provides dummy webservices for itself. In the real world it could call webservices on another machine, but during development and testing we need be able to access the internal webservice to populate tables. This can't be done during the bootstrap as the internal webserver has not started yet (Grails doe...

Grails .grails and .ivy2 directories

Using Grails 1.2.1, is there any way to specify where the .grails and .ivy2 directories should be stored? Currently they are being placed in our profile, which is causing problems with the way our environment is set up. We can just delete the directories before we log off and have Grails re-populate them when we next run it, but that's ...

Getting list of files

I have a directory named 'import' and would like to get all files and their corresponding date (based on filename). Sample content of the directory is this: input_02202010.xls input_02212010.xls input_02222010.xls I would like to have a Map that contains the path of the file and a Date variable. Can anyone show me how Groovy will s...

Grails scaffolding link reference problem

Hi, I'm using scaffolding for a couple of Controllers for two Domain Classes: 1 Sector to N Items: class Item { String name static belongsTo = [sector:Sector] .... } class Sector { String name static hasMany = [items:Item] .... } When I generated the corresponding scaffolding controllers I used the pattern (class)mgr: Sectorm...

How do you manage the configuration of a grails application deployed as a "product"?

I've recently written my first grails application. The application is a "product" in that I'd like to build a single version of the application that can be deployed to multiple customers as a war file. I need to be able to configure each application differently. What is the "best practice" for deploying a grails application as a prod...

Grails criteria projections - get rows count

I have Hotel entity: class Hotel { City city } Now, i need count of hotels with given city. It could be done in this way: def hotels = Hotel.findAllByCity(city) def cnt = hotels.size() But it's very dirty way. It seems that with criteria it would be better, but i have no idea how to implement it... ...

How do you persist a collection of Enums in Grails?

Any ideas on how to persist a collection of enums in Grails? Groovy enum: public enum MyEnum { AAA('Aaa'), BEE('Bee'), CEE('Cee') String description MyEnum(String description) { this.description = description } static belongsTo = [tester:Tester] } I want to use this enum in a Grails domain class. The domain class l...

How to add an index to the DB column 'class' used for inheritance in Grails?

Hi, When using table-per-hierarchy inheritance, GORM creates a 'class' column that stores the classname of instances. I want to add DB index to this column, since many of my SQL queries include where class='com.myapp.Mychildclass' . However, I didn't succeed with this code: static mapping = { columns { 'class' column:...