groovy

Groovy List Conversion

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

Coerce result row into object

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

A Groovy Web Console in a Java webapp?

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

generics in Groovy

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

Java or Groovy CMS

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?

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

Adding a Groovy Class to a Google App Engine Project (groovy-plugin, google-plugin)

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

How much will JSR-292 (invokedynamic) do to Groovy performance?

Is there an estimate that says how much JSR-292 will impact Groovy performance? ...

How to mock/stub calls to message taglib in Grails controller

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

Invoking Groovy closures

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

Groovy way of doing it in Grails

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

jar file in Grails project lib directory not found

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

Assignment and condition evaluation in one step

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

Groovy findAll and each tag question

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

Groovy on Grails - Sorting list output without having to have a SortedSet or Comparable model?

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

How to define in Grails an uploadForm and 2 different actions ?

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

Does anyone have a TextPad syn file for GSP?

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

worth to learn groovy?

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

Field Expression in ireport

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

Grails shell not seeing domain objects

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