grails-validation

Grails validation of a list objects

I'm trying to get grails to validate the contents of a List of objects, might be easier if I show the code first: class Item { Contact recipient = new Contact() List extraRecipients = [] static hasMany = [ extraRecipients:Contact ] static constraints = {} static embedded = ['recipient'] } class Contact { Str...

parameterized Grails validation messages

Hi, In the messages.properties file in a Grails application I've seen examples of validation messages such as: User.password.size=Size of bar must be between {0} and {1} which applies to class User { String password static constraints = { password(size:5..15) } } This example assumes that {0} is bound to the m...

Dependency Injection In Grails Domain Controllers

I'm trying to create a a custom constraint. I've put the logic in a service: class RegExpManagerService { boolean transactional = false def messageSource def lookupRegexp(regExpression,Locale locale) { def pattern = messageSource.getMessage( regExpression,null,locale ) return pattern } def testRegex...

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

How To Know The Cause Of A Validation Error

The following code will throw a grails.validation.ValidationException if the save fails for some reason. But the result is a generic error. How can I know the actual cause of the error so I can report it back to the user? def addChild(cName,Parent theParent) { println "add child: ${cName}" def theChild = new Child(name:cName,pa...

Render Errors From A Service

I call a service that creates a parent and a child record. If an error happens, the service throws a RuntimeException. The RuntimeExceptionis is caught by the controller and then there there is a redirect back to the gsp. But the error is not being rendered. In this case, I guess the controller and thus the gsp doesn't really no anythin...

grails gorm with multiple data sources

I am working on an application using grails to bridge the gap - supporting legacy POJO code, adding things like better session management. the current implementation relies on 3 database connections 1. hibernate hsql memory based for session management 2. oracle 10g connection to legacy database 3. oracle 10g connection to separate data...

Grails bindData exclude not excluding

I'm trying to use 'bindData' method and exclude one field like so: bindData(person, params, [exclude: ['responseItems']]); I thought that by listing the 'exclude' parameter, when bindData iterates over 'params', it would ignore the key-value pair specified in the array but it doesn't appear so. Instead, I'm getting an error: org....

Grails client side validation

Hi ! How do you (if you) manage client side validation with grails ? Do you use a plugin or do you mirror your constraints using a javascript framework ? Cheers ...

Grails: nested command objects

Hi, In my grails app I have an outer command object that contains a list of other command objects: public class OuterCommand { List<InnerCommand> innerCommands = ListUtils.lazyList([], FactoryUtils.instantiateFactory(InnerCommand)) } class InnerCommand { String code Long id String value static constraints = { ...

Getting Stack Overflow when including query in grails validator

altEmailAddress(blank: true, nullable: true, validator: { if (it == null || it == '') { return true } else { return (User.countByEmailAddress(it) > 0 && User.countByAltEmailAddress(it) > 0) } } Stack trace: Testcase: testFindValidEmailAddress took 0.429 sec Caused an ERROR null java.lang.StackOverflowE...

Grails domain class constraints for relation between fields

Hi, I need to write Domain class constraint in Grails which says that one integer field must be greater or equal than the other. When I write the code like this: class MyDomain { String title int valueMin = 1 int valueMax = 1 static constraints = { valueMin(min:1) valueMax(min:valueMin) } } I'm getting error: Caused by: ...

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 and AJAX: Grails form validation working using ModalBox or YUI2 Dialog ?

Several Grails applications, like the one I'm writing, require a /user view and /admin view that are 'dashboards', basically the user or admin lands on that page, possibly after a successful login and all the datatables and tabs are there, so they hardly ever need to navigate off that page, providing a more satisfying users experience, l...

Grails Problem with custom error messages

Hi, I am currently trying to specify custom error messages in grails for the default constraints but so far all I get back is the default error message. I know that I have to edit the grails-app/i18n/messages.properties file If I change the following default error codes message, it will correctly display the new error message default...

Displaying Grails Field Errors

Does anybody know how I could get the fieldError to print out in the example below. for each item with an error, I would like to print custom error messages that I have defined in the messages.properties file at the moment all this does is print the default error codes item.errors?.allErrors?.each{ println it.toString() }; I have ...

Grails - testing custom validator on domain class issue

I'm learning grails from Grails - getting started by Jason Rudolph book. My domain class looks like that: class Race { String name; Date startDateTime String city String state Float distance Float cost Integer maxRunners = 10000 static hasMany = [registrations: Registration] static constraints = { name(maxSize: ...

Grails validation issue on multi-domain association ?

I need to validate save action between 3 domains, here is relationship : User - JobProcess : one-to-many, JobProcess - Heatmap : one-to-many. User { static hasMany = [ jobs : JobProcess ] ... } JobProcess { static hasMany = [ heatmaps : Heatmap ] ... User script ... } Heatmap { static belongsTo = JobProcess ... JobProcess job ... } I...