groovy

Learning Ruby on Rails any good for Grails?

My company is in the process of starting down the Grails path. The reason for that is that the current developers are heavy on Java but felt the need for a MVC-style language for some future web development projects. Personally, I'm coming from the design/usability world, but as I take more "front-end" responsibilities I'm starting to fe...

How to setup Groovy + Eclipse + Junit4 ?

I am working on a small webapp and I want to use Groovy to write some unit testing for my app. Most of my coding is done on Eclipse and I really want to run all the unit testing with the graphical test runner within Eclipse (I really like the green bar :) ) Sadly, after 4 hours of try-and-error, I'm still not able to setup properly. I t...

shortcut for creating a Map from a List in groovy?

I'd like some sorthand for this: Map rowToMap(row) { def rowMap = [:]; row.columns.each{ rowMap[it.name] = it.val } return rowMap; } given the way the GDK stuff is, I'd expect to be able to do something like: Map rowToMap(row) { row.columns.collectMap{ [it.name,it.val] } } but I haven't seen anything in the docs... ...

HTML using Groovy MarkupBuilder, how do I elegantly mix tags and text?

When using Groovy MarkupBuilder, I have places where I need to output text into the document, or call a function which outputs text into the document. Currently, I'm using the undefined tag "text" to do the output. Is there a better way to write this code? li{ text("${type.getAlias()} blah blah ") function1(type.getXYZ()) if (ty...

What is a MUST COVER in my Groovy presentation?

I'm working on getting an Introduction to Groovy presentation ready for my local Java User's Group and I've pretty much got it together. What I'd like to see is what you all think I just have to cover. Remember, this is an introductory presentation. Most of the people are experienced Java developers, but I'm pretty sure they have li...

How can I convince GroovyShell to maintain state over eval() calls?

I'm trying to use Groovy to create an interactive scripting / macro mode for my application. The application is OSGi and much of the information the scripts may need is not know up front. I figured I could use GroovyShell and call eval() multiple times continually appending to the namespace as OSGi bundles are loaded. GroovyShell maintai...

What are some advantages of duck-typing vs. static typing?

I'm researching and experimenting more with Groovy and I'm trying to wrap my mind around the pros and cons of implementing things in Groovy that I can't/don't do in Java. Dynamic programming is still just a concept to me since I've been deeply steeped static and strongly typed languages. Groovy gives me the ability to duck-type, but ...

How to check if element in groovy array/hash/collection/list?

How do I figure out if an array contains an element? I thought there might be something like [1,2,3].includes(1) which would evaluate as 'true' ...

What Java versions does Griffon support?

I want to write a Swing application in Griffon but I am not sure what versions of Java I can support. ...

Is anyone developing facebook apps on Grails

I have not seen much support for Grails to develop facebook apps.I was just wondering if people around are developing facebook apps on grails ...

Rails or Grails?

Grails vs Rails. Which has better support? And which one is a better choice to develop medium size apps with? Most importantly which one has more plug-ins? ...

How do I use groovy to search+replace in XML?

How do I use groovy to search+replace in XML? I need something as short/easy as possible, since I'll be giving this code to the testers for their SoapUI scripting. More specifically, how do i turn "<root><data></data></root>" into "<root><data>value</data></root>" ...

UI design alternatives with Groovy/JRuby/Jython or other JVM languages ?

For a developer in the Java eco-system, there is a handful of choices when it comes to UI design. The best known are: Swing (preferred when used with Netbeans and its GUI builder) Eclipse's SWT (mostly preferred for Eclipse plug-ins) Now, are there any frameworks or design alternatives to this which target JRuby / Groovy / Jython or ...

How do you parse a web page and extract all the href links?

I want to parse a web page in Groovy and extract all of the href links and the associated text with it. If the page contained these links: <a href="http://www.google.com">Google&lt;/a> <a href="http://www.apple.com">Apple&lt;/a> The output would be: Google, http://www.google.com Apple, http://www.apple.com I'm looking for a Groovy an...

What's the definitive Java Swing starter guide and reference?

Obviously the Java API reference, but what else is there that you all use? I've been doing web development my entire career. Lately I've been messing around a lot with Groovy and I've decided to do a small application in Griffon just to experiment more with Groovy and also break some ground in desktop development. The only thing is ...

Groovy: Correct Syntax for XMLSlurper to find elements with a given attribute

Given a HTML file with the structure html->body->a bunch of divs what is the correct groovy statement to find all of the divs with a non blank tags attribute? The following is not working: def nodes = html.body.div.findAll {it.@tags != null} because it finds all the nodes. ...

error while using groovy.sql Out parameter.

I am trying to execute some stored procedures in groovy way. I am able to do it quite easily by using straight JDBC but this does not seem in the spirit of Grails. I am trying to call the stored procedure as- sql.query( "{call web_GetCityStateByZip(?,?,?,?,?)}",[params.postalcode, sql.out(java.sql.Types.VARCHAR), sql.out(java.sql.Type...

How to pipe stdout from a groovy method into a string

How do you invoke a groovy method that prints to stdout, appending the output to a string? ...

Is there a source code formatter for Groovy?

I use the commercial version of Jalopy for my Java projects but it doesn't work on Groovy files. IntelliJ has a serviceable formatter but I don't like requiring a particular IDE. ...

Grails 1.0.3 console reports 'premature end of file'

Browsing to a dynamic web page built using Groovy on Grails version 1.0.3 the console log shows the following errors for each page request: [Fatal Error] :-1:-1: Premature end of file. How do I stop this error from appearing for each request? ...