I'm having an issue in groovy trying to figure out how to convert a single item to a list. I have an incoming variable params.contacts, which could be a single value (e.g. 14) or it could be an array of values (e.g. 14, 15). I want to always turn it into a list. Previously, I was simply saying params.contacts.toList(), but this code f...
Is there a way to coerce the result row gotten from calling a stored procedure into a specific object so I can pass just a list of that object into the view?
I know I can use things like Node.list() to do this, but I am eventually going to replace getnodes() with a fairly complicated stored procedure that creates temp tables and does so...
I've been looking at Groovy a little lately, and I love the idea of the Groovy Web Console.
I'm idly wondering whether there's a way to embed a simple web control to write and run scripts from in a web app I might put together myself.
Is there a plugin-style solution to embed a control like this?
Are there any resources or guidance ou...
Hi,
The following Groovy code prints "it works"
def printIt(Class<? extends Exception> clazz) {
println "it works"
}
printIt(String.class)
even though the parameter doesn't satisfy the constraint Class<? extends Exception>
My understanding is that this is because:
Type erasure in Java generics means there's no run-time generic...
Hi,
I'm considering developing a school information system using the Grails web framework. Before a school can use the system, they will need to setup the following data
School data
Students
Teachers
Subjects
Classes
etc.
I'm considering using a CMS in order to get the ability to CRUD these entities "for free". The CMS may also pro...
Using Groovy (or Java) how can I convert a org.joda.time.LocalDateTime to a java.util.Date?
import org.joda.time.*
Calendar cal = Calendar.instance
cal.set(Calendar.DATE, 1)
cal.set(Calendar.HOUR, 0)
cal.set(Calendar.MINUTE, 0)
cal.set(Calendar.SECOND, 0)
cal.set(Calendar.MILLISECOND, 0)
Date startOfTheMonth = cal....
I've heard that GAE now supports Groovy, but it seems the plugins don't work so well together. I'm trying to make a GAE project in eclipse that I can add Groovy Classes too...but it won't work. Everytime I try to add a Groovy Class I get the error 'Project is not a Groovy Project'. And when I go to Configure - Convert to Groovy Project, ...
Is there an estimate that says how much JSR-292 will impact Groovy performance?
...
I've got a Grails controller which relies on the message taglib to resolve an i18n message:
class TokenController {
def passwordReset = {
def token = DatedToken.findById(params.id);
if (!isValidToken(token, params)) {
flash.message = message(code: "forgotPassword.reset.invalidToken")
redirect controller: 'forgotP...
Hi,
If I define a closure in Groovy
def c = {println "foo"}
I can invoke it using either
c()
or
c.call()
AFAIK, these two are identical. However, I recently discovered a third way
c.doCall()
Are there any differences between call() and doCall()
Thanks,
Don
...
Article {
String categoryName
static hasMany = [
tags: Tag
]
}
Tag {
String name
}
Now I want to find the list of all related articles. Related meaning, all articles that have the same category name as myArticle or any of the same tags as myArtcle.
With only matching categoryName, here is how I would get...
I have a grails project and a jar file in the lib directory of the grails project. The problem is when i run the app I get class not found errors on classes within the jar file. Why can these not be seen by the grails app?
...
Hi
I have this code
def errorMap = validateParams(params)
if (errorMap) {
flash.errorMap = errorMap
return
}
My question is this: Can I combine the assignment in line #1 and evaluation of the condition in line#2 to make a one liner like the following:
if (flash.errorMap = validateParams(params)) {
return
}
Is it a bad pr...
Hi
I have the following domain classes:
class User = {
String username
...
Company company
}
class Company {
String name
...
}
That is, there is a n:1 relationship between user and company.
These classes are so and I cannot change them.
At the show.gsp I want to have the details of the company togethe...
I am banging my head up against the wall about what I think would be a very simple problem to resolve in Grails:
Say that I have shopping-cart-like model; so a class Cart that hasMany items, and each item belongsTo the cart. In general, I don't care about the order of the items in the cart - I don't care what order they're stored in, c...
I have a gsp view, with an , and 2 input text.
I have a button to save and submit.
Now I would like to add another button with a new action, in my case a button to schedule save.
Note : in my controller I have define : def save (corresponding to button action save) and def schedule (corresponding to button action schedule).
What is th...
I am looking for a syntax hilighting file for Textpad which hilights the Groovy g namespace. I have been trying to build one myself and can't quite figure out how to do it - or whether it is possible to have namespace based syntax hilighting in TextPad at all.
I have a great one for Groovy, but nothing yet for GSP. Has anyone created ...
the question im asking, is it worth to learn a new language like groovy? cause if i learn groovy, it feels like i code in groovy and not java. and how smart is that when i have to be good in java to code desktop applications too in the future. so if i use groovy a lot for web applications, i will just be worse and have to start over to b...
Hello!
I'm trying to get myself used to jasperforge ireport before using it in a real project next week and i seem to be stacked somewhere already .i'm using ireport 3.7.0 on windows xp platform + java 1.6
It sound easy to get a field color changed based on what it contains or calculate a sum of number in a field based on conditions ...
Hi, I'm a grails newbie (and a groovy newbie), and I'm working through some grails tutorials. As a new user, the grails shell is a really useful little tool for me, but I can't figure out how to make it see my classes and objects. Here's what I'm trying:
% grails create-app test
% cd test
% grails create-domain-class com.test.TestObj
...