grails

Grails/Groovy: URL params (max, offset) NumberFormatException thrown when blank/strings

in the controller params.max = Math.min(params?.max?.toInteger() ?: 10, 20) params.offset = params?.offset?.toInteger() ?: 0 if you enter in the following urls /books?offset=10&max= //error /books?offset=10&max=sdf //error /books?offset=&max=10 //works /books?offset=adsfa&max=10 //error java....

Grails/AJAX: Updating an arbitrary region in the page using g:submitToRemote

In a GSP (Groovy Server Page), I'm using <g:submitToRemote update="..."> to update a <div> after the server-side call. According to the tag's documentation and other sources on the web, the target <div> can be placed arbitrarily at the page. In my testings, however, I find that the <div> needs to surround the <g:submitToRemote> tag. I...

Domain object referring to a reference table in Grails GORM

I have a domain object called User: class User{ String username; String firstName; String lastName; Zipcode zip; } I also have a Zip Code object: class Zipcode { String zip; String city; String state; Float lat; Float long; } The zipcode table should never be modified as it contains static reference data prepopula...

Grails Dependency Injection Problem

Hi, I am having problems when using dependency injection with Services in Grails. class ExampleService{ def example2Service def example3Service def method1(){ def result = example2Service.method2() } } class ExampleService{ def example3Service def method2(){ def result = example3Service.metho...

Is there an option for toggle watchpoint in debug perspective on STS 2.5.0 RC1 for Grails?

Heres is what I'm currently looking (sample project from a Grails book): http://yfrog.com/f/ekkapp/ I’m trying to use STS 2.5.0 RC1. On the sample app that I’m working on to learn Grails, I’m getting some unexpected results on the UI. I’m passing in the user, and I’m not getting redirected to the Todo List. So, in the action method I w...

Grails: domain class mapping (collection of hibernate user types)

Hello, I am wondering if is possible to implement following domain model. Let's have a domain class which contains set of intervals (joda time). I can use org.joda.time.contrib.hibernate.PersistentInterval hibernate user type for mapping of Interval to database table (by similar way as in http://www.grails.org/JodaTime+Plugin). However...

Why does grails URL params decoding behave differently on server vs. local

Let's say I have the following entry in my grails URLMappings.groovy: "/actionName/param1"(controller:'myController', action:'myAction') When I call an URL where param1 includes + as a special character, the URL is encoded correctly to /actionName/my%2Bparam for example, both in my local and in my server environment. In my local envi...

window/Linux Specific filesystem properties in Grails

hi, I want to add linux based or windows based system properties in Grails as my app needs to run in the both. I know that we can add grails.config.locations location specified in Config. groovy. But I need the if and esle condition for the file to be picked. the problem is config.grrovy has userHome grailsHome appName appVersion I w...

Grails: How to make everything I create Upper Case?

Hello, I am currently using CSS to change everything I write to upperCase when I create an entry, but that is not enough. When I save things, the text shown in the text fields is upper case, but the real value that Grails stores stays in lower case. I am assuming I'd need to change something in the controller or anything. Maybe transf...

Authenticating to Spring Security after authenticating to Twitter / Facebook

I have a grails app configured with spring-security-core and I need to allow Facebook / Twitter logins. I'm using the facebook plugin for grails and I'm using twitter4j for twitter authentication. Currently, I am successfully authenticating against Twitter and Facebook. I'm wondering how I am to integrate those logins with Spring secu...

Error including the TestApp script in grails

Hello I have a simple script as shown below: I am getting following error on running this script. includeTargets << grailsScript("Init") includeTargets << grailsScript("TestApp") target(main: "The description of the script goes here!") { echo "This is the start" } setDefaultTarget(main) Environment set to test Error execu...

Booleans in grails aren't persisted?

Hello, I'm developing a small application on Grails 1.3.5 and I run into this very strange problem. My domain classes feature some boolean typed fields. None of these fields is persisted when creating a new instance (and saving it of course). For example, I have this domain class "Employee", defined as follows (simplified): class Emp...

Grails: GET a large dataset and POST a significant amount of params (best method)

I need to GET a large collection in a form, and POST a large selection of user ids from the collection to a controller. Q Whats the best way to load a large collection and submit a large amount of params. Break down:(Getting) there might quite a number to choose from so I wouldn't want to load the complete collection incase memory prob...

Grails 1.3.5: How to configure Datasource.groovy to either connect to MySQL or SQL Server

Hi, The grails application I am developing could run against MySQL or SQL Server. I want to add a new property in application.properties file say database.type=MySQL // or it could be SQLSERVER How do I get this property in Datasource.groovy so that if it is MySQL I connect to MySQL server or it is SQLSERVER I connect to SQL Server...

grails paginate with a list from a 1:m relationship

In the case below an author object has an existing list of 'books'. How do you paginate through this list of books if the controller already has an 'author' object and you do not want to go back to the DB with another request of Book.findAll("from Book as b where b.author=:author", [author:author], [max:10, offset:5]) class Author { ...

grails unidirectional one-to-many

this has been bugging me, lets say i have two model, category and product class Category { static hasMany = [products : Product] String name } .. class Product { String name } now, i want to delete product, which happens to exist in many category. i came up with these lines in my product beforeDelete methods def beforeDelete =...

How do I fake a validation error?

I'm using the Grails Webflow plugin. Here are the domain objects I'm working with: class Foo implements Serializable { String fooProp1, fooProp2 static constraints = { fooProp2 nullable: false } } class Bar implements Serializable { Foo fooObject static constraints = { fooObject nullabl...

Grails Logging during integration tests

Hi, I've got few issues with Grails logging during test [running grails test-app, Grails 1.3.5]: 1 I've got some debug/info logging in my application and it works fine when running the app [grails run-app]. However when I want to test my app, none of it is written to the System.out/System.err files nor to file appender. How can I enab...

Violation of Unique Key constraint

I am using grails, and I am getting the following when trying to create a new EducationType in my controller 2010-10-26 17:14:49,405 [http-8080-1] ERROR util.JDBCExceptionReporter - Violation of UNIQUE KEY constraint 'UQ__educat ion_type__0519C6AF'. Cannot insert duplicate key in object 'dbo.education_type'. 2010-10-26 17:14:49,409 [ht...

Determine if the month is almost over in Groovy

I am trying to figure out the best way to determine if a given Date is 10 days or less from the end of the month. I am basically building functionality that will display a message if the month is almost over. Thanks! ...