groovy

Load, modify, and write an XML document in Groovy

I have an XML document that I want to load from a file, modify a few specific elements, and then write back to disk. I can't find any examples of how to do this in Groovy. ...

Intercept service method calls using metaprogramming in groovy/grails

Hi, I have a several Grails services that are invoked from Flex code using Spring BlazeDS integration. I wanted to add some general debug logging using the groovy metaClass. I have the following in a bootstrap class: class MyBootStrap { def grailsApplication def init = { servletContext -> initServiceCallLogging() } def destr...

Substituting Groovy for Java Little By Little

I have been checking out Groovy a bit and I feel that moving a Java program to Groovy little by little -- grabbing a class and making it a Groovy class, then converting the method guts a bit at a time -- might be a relatively sane way to take advantage of some of the Groovy language features. I would also do new classes in Groovy. Quest...

Moving From non-Java Ruby to Groovy: Language Differences

Using my not-outstanding Google skills, I have not been able to find a decent tutorial on Groovy for Ruby programmers. There are a lot of political pieces (Ruby is great! Groovy is great!) and tiny little contrasts, but I really don't care which is better. I know Ruby (and Java) relatively well, and I'd like to learn Groovy. Would anybo...

Grails Domain Class Dynamic List As A property

Let's say I have a domain class called ShopCategoryPageTab. And I have a domain class called Product. I want ShopCategoryPageTab to have a list of Products. However, this list is not static, but determined by a formula. For example, I might want to have a "products" property which would list all products with criteria X, Y Z. So this...

Poor debugging support for Grails web app in Eclipse

Hi, I'm an everyday C#/ASP.NET MVC/Visual Studio user and i've just started a project in JAVA/GRails/Eclipse but i'm finding it quite difficult to use Eclipse's debugging features and find them somewhat limited compared to Visual Studio's. In particular, i'm finding the following rather disappointing but i don't know if they're limitati...

Does Sitemesh work with Gaelyk ? Does anybody have a working guide?

Has anyone been able to get sitemesh and gaelyk working together? This seems to be possible as mentioned here http://blogs.bytecode.com.au/glen/2009/12/14/getting-sitemesh-running-on-google-app-engine.html. However I unable to get this working with a gaelyk template. I keep getting this error "javax.servlet.ServletException: Creat...

Explicit typing in Groovy: sometimes or never?

[Later: Still can't figure out if Groovy has static typing (seems that it does not) or if the bytecode generated using explicit typing is different (seems that it is). Anyway, on to the question] One of the main differences between Groovy and other dynamic languages -- or at least Ruby -- is that you can statically explicitly type varia...

How can I import one Gradle script into another?

Hi all, I have a complex gradle script that wraps up a load of functionality around building and deploying a number of netbeans projects to a number of environments. The script works very well, but in essence it is all configured through half a dozen maps holding project and environment information. I want to abstract the tasks away i...

dynamically set the db in a sql query

I try to run the same query in several dbs in mysql: def m='xxx' def dbs = ['DB05DEC05','DB06DEC06','DB07DEC07','DB08DEC08','DB09DEC09','DB10DEC10'] def sql =Sql.newInstance("jdbc:mysql://localhost:3306", "root","", "org.gjt.mm.mysql.Driver") dbs.each{ db-> sql.eachRow("select * from ${db}.mail where mid=$m", { println "\t$db ${it.mid...

How do I create an XPath function in Groovy

I'm trying to create a function in Groovy that does the following: Accepts 2 parameters at runtime (a string of XML, and an xpath query) Returns the result as text This is probably quite straightforward but for two obstacles: This has to be done in groovy I know next to nothing nothing about groovy or Java… This is as far as I've...

Groovy Sql and SimpleDateFormat help

In my database, I have a column type : datetime. Column data example : 2009-02-03 19:04:23.0 I'm using : SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); to define my date format. I'm using groovySQL to read tables and for each rows, I'm adding a new SampleJ object (mapped to a new table - SampleJ). Here my...

Deploy Grails to a Sub-Context Path

I would like to deploy a grails war to a sub context path but when I try this the application will not load and an error filterStart so I'm either missing something or grails can't be deployed to a sub-context. Is there any way to load grails in a sub context? ...

Using XmlSlurper in Groovy / Grails to parse a Pingdom XML response

I have used XmlSlurper successfully before, but am struggling to parse the following XML - it is a response from a call to the Pingdom API. I have tried following the namespace declaration examples, but I just get an error message on the ns1 and ns2 values. Can anybody help point me in the right direction? The xml looks like this:- <?x...

GSP Editing in Netbeans 6.8

Hello guys. I have a problem with Netbeans 6.8 and GSP pages. Format and indent working but provides invalid structure. Moreover Netbeans highlinging page directive as error. And code completion is not working too. Is it a bug or smth need to be fixed in my settings or Netbeans does not provide such features. In this archive you can ...

Grails config of Spring beans in different files

Grails have cofig for spring bean called resources.groovy. And as i understand from docs it allows you to include another file, using loadBeans(%path%) I'm tried with this: println 'loading application config ...' // Place your Spring DSL code here beans = { loadBeans("classpath:security") //i'm tried with "spring/security" and "...

TablePerHierarchy always false for abstract classes?

According to the Grails GORM guide, subclasses of domain classes share the same table as the parent class unless tablePerHierarchy is set to false. I cannot find information on whether the following mapping statement is ignored because of the "abstract" keyword abstract class Item implements Comparable{ static mapping = { tablePe...

Rendering HTML files in Grails

Hi all, I've looked around but could not find a way of simply including or rendering *.html files in Grails. My application needs to g.render or <g:render> templates which are delivered as html files. For this, as we know, html files have to be converted to _foo.gsp files in order to get rendered. I am totally surprised as to why isn't ...

How to use opencsv with my collection (list) ?

I need to parse 2 dimensional list, here is my schema list : list (size=12) ->[0] = "export.SampleJ:12432" --> id = 12432 --> dateCreatedSample = "Tue Feb 03 19:04:23 CST 2009" --> ttId = 0 --> chipId = 1012 --> ... ->[1] = "export.SampleJ:12433" --> id = 12433 --> ... ->[2] ... I tried : List<Strin...

groovy swingbuilder bindable list and tables

Is there a way to bind data to a list and/or a table using the groovy swing builder bind syntax? I could only find simple examples that bind simple properties like strings and numbers to a text field, label, or button text. thanks, Jeff ...