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