Hello, I'm having a problem while using constructors with a Groovy class.
I have a class Data in a file called Data.groovy with an inner class ContentEntry. I want to initialize ContentEntry instances from a Data method:
static void initContent(nid, uid)
{
curContent = new ContentEntry()
curContent.nid = nid;
curContent.uid...
Hi,
The following Groovy code:
1.upTo(5) {println it}
Produces this compilation error:
No signature of method:
java.lang.Integer.upTo() is applicable
for argument types:
(java.lang.Integer,
ConsoleScript4$_run_closure1) values:
[5,
ConsoleScript4$_run_closure1@e83c97]
It appears that the method call matches the sign...
Hi
I have an Groovy appilcation using Acegi Spring Security.
My User Class looks as follows:
class User {
static constraint = {
email(blank:true, nullable:true)
description(blank:false, nullable:false)
username(blank: false, unique: true)
userRealName(blank: false)
company(nullable:true, blank:true)
authorit...
My simplified domain model in grails is like this:
Article {
Integer totalViews
static hasMany = [
ratings: Rating
]
}
Rating {
Integer value // 1 to 5
User user
}
I am trying to find the 5 most popular articles based on totalViews and ratings, say 25% weightage on views and 75% weightage on ratings.
How ...
I know this is a duplicate, however, the Grails world has moved on considerably since that question was asked more than a year ago, as has the IDE support in Eclipse, so please don't just blindly close it.
I thought the answer was yes and have embarked on a new project with Grails 1.2.0 and have flirted with the Groovy/Grails bits of ...
Hi!
I have a Groovy application and I want to access programatically to a property
defined in message.properteies.
As a test I've tried the following:
println "capacity.created " + ${message.properties['capacity.created']}
But it doesn't work (throws an exception).
Any help is welcome
Luis
...
In Spring Roo if I don't want a specific method to automatically be generated I can remove an annotation. Is there a way to do this in Grails? For example I would like the list and create methods of a controller to automatically be updated with any changes in the domain model when I do a generate-all, but would like to use custom code fo...
I'm trying to derive the class instance of a groovy class from the name of string.
For example, I'd like to do some code along these lines:
def domainName
domainName = "Patient"
// but following line doesn't work, domainName is a String
def domainInstance = domainName.get(1);
...
What is the best way to determine the data type in groovy?
I'd like to format the output differently if it's a date, etc.
...
I'm making a web application with Grails. I've got a list with data that must be included on JavaScript to perform some dynamic load on drop-list. Basically, I'm getting a two level list from the server, then the first level is presented on a drop box. When the user selects an option, the list associated to this option is presented on a...
I start an external groovy script via cruisecontrol, which basically works. My problem is that if the groovy script fails I only get the "error string found" in my cruise webapp and email; its even not in the log files. The groovy script writes it output to stdout and to a logfile. How it is possible to display the output of an external...
Hi,
I'm writing a tag that essentially needs to dump an arbitrary domain class for the fields requested via parameters to the tag. This works fine if the field is a normal attribute. But, if it's a "hasMany" relationship, what are my options?
In other words, how do I check if a string passed as a parameter to the tag corresponds to a ...
I have an Expando class which I need to inspect its properties from Java.
In Groovy:
def worker = new Expando()
worker.name = "John"
worker.surname = "Doe"
In Java:
Introspector.getBeanInfo(groovyObject.getClass())
Is it possible to compile at runtime the class from the object in Groovy?
...
The Groovy "in" operator seems to mean different things in different cases. Sometimes x in y means y.contains(x) and sometimes it seems to call y.isCase(x).
How does Groovy know which one to call? Is there a particular class or set of classes that Groovy knows about which use the .contains method? Or is the behavior triggered by the ...
I'm working on a large existing java project using maven to manage our builds / releases.
I'm interested in using groovy to replace some of our Java classes where we can benefit from it's dynamic nature.
How do I go about doing this using maven?
...
I am building a multi-languages grails website and I need to get the ordinal suffix of a number for several languages like English, French, Spanish, German and Italian.
I believe that this issue is quite common for multi-languages website owners. I have found this article that provides a solution but it is English only.
For instance:
...
Hi!
I have a Grails application with a -simplified - domain class which looks like this:
class Capacity {
static constraints = {
month(blank:false, nullable:false)
company(blank:false, nullable:false)
}
Date month
Company company
String note
...
}
The pair month-company must be unique. (I.e. they should b...
I'm trying to implement a domain class that records when any property's value was changed, but my setProperty() call results in infinite recursion when setting the actual value.
This is how it looks right now:
void setProperty(String name, value)
{
if(name == "modified")
{
this.modified = value
return
}
...
This one has been driving me crazy today. Since upgrading to Grails 1.2 and Weblogic 10.3 the default root mapping for "/" stopped working. Here's what I have...
I have this URL mapping:
"/"(controller:"IGive", action:"index" )
I have a controller named IGiveController with an index closure
def index = {
render "foo"
}
When ...
It is possible to use Adobe Flash as view in Grails project? I want that all logic: model and controller was written on Grails, and use Adobe Flash. It's will be perfect to have some link on examples.
...