groovy

Dynamic languages - which one should I choose?

Dynamic languages are on the rise and there are plenty of them: e.g. Ruby, Groovy, Jython, Scala (static, but has the look and feel of a dynamic language) etc etc. My background is in Java SE and EE programming and I want to extend my knowledge into one of these dynamic languages to be better prepared for the future. But which dynamic l...

code formatter for grails and Groovy?

I'm currently using a basic text editor to write my grails code. Does anyone know of a program that will automatically format code with indentation similar to indent does for C? I'd rather use a commandline program to do this but can use an IDE to format my code if that's the only option. ...

omitting 'def' in Groovy declarations

Hi, In Groovy, it appears that the following declarations are both legal private final results = [] private final def results = [] Is there any difference between these two? Thanks, Don ...

Saving associated domain classes in Grails

I'm struggling to get association right on Grails. Let's say I have two domain classes: class Engine { String name int numberOfCylinders = 4 static constraints = { name(blank:false, nullable:false) numberOfCylinders(range:4..8) } } class Car { int year String brand Engine engine = new Engine(...

Can anyone recommend a java web-framework for large application?

We are going to start a large and scalable application which has around 50,000 to 200,000 users. my partner told me Both Groovy and OpenXava are framework for small development. My co-worker told me Both Groovy and OpenXava are framework for small development. i want to know if it's true or which framework do you recommend me. ...

How to create "clone" of controller in Grails ?

Hi, I have a menu that loaded from main layout. in the menu I have to highlight the specific menu if users click on that menu. I detect it based on Controller name. I have 2 menu that has different names ie Users Edit and Client Edit. Both actually share the same controller (ie: UserController) and same Domain. I tried to create ali...

Grails belongsTo, should I ?

Hi, let's go straight to the problems (with Grails 1.1.1, it should work on previous one) I have 2 domains ie: User and Detail like this : Class User { String userName ; ..... // another fields static hasMany = [details:Detail]; } Class Detail{ String detailName ; ... // another fields static belongsTo = [user:Use...

pass data from controller to filter

Hi, In a Grails application I'm looking for some way to pass data from a controller action to a filter that runs after the action. I was thinking of something like: class MyController { def myAction = { render(view:"myView", model:[key: "value"]) passData { // Do some processing here name = ...

Can generic XML by parsed as nicely as simple XML in Groovy?

Given a nice, simple XML structure, XmlSlurper() can allow me to read values from it very easily. def xml = "<html><head><title>groovy</title></head></html>" def html = new XmlSlurper().parseText(xml) println html.head.title Is there a way to make this simple tree navigation possible for generic (type-based, etc) XML. Ideally, in t...

Can I insert debugger statements inside my Groovy code?

Both Ruby and Python have the ability of calling the debugger from code ( using the ruby-debug gem or the pdb module ). I'd like to know if something like that's available for Groovy. I'm not interested in debugging with the IDE. ...

How can I access the Groovy setter shortcut for multiparameter setters?

Let's say I have a java.util.Properties object. The Properties object has a method called setProperty(String name,String value). Is there a setter shortcut for it? EDIT: maybe the Properties class was not the best example, because I think it handles that by adding the keys as properties. But how about a setter method that takes an arbit...

Groovy rootLoader is null

When running a groovy script from Eclipse, the following line: def rootLoader = this.class.getClassLoader().getRootLoader() is null. When I run the script directly from command line, this is not null. How can I find out why this happens? ...

Scoping of Open classes in Ruby versus MOP in Groovy

What I'm trying to find out is whether there is some sort of equivalence to what I see in Groovy as ExpandoMetaClasses. I've been reading about Open Classes but I can't quite see what level of scoping Ruby allows of the class modifications. Borrowing an example from the blog above, in Groovy, I could modify Java's String class and add ...

org.w3c.dom.Document to XML string using Groovy

I have an org.w3c.dom.Document instance which I need to convert to an XML string. I know how to do this in Java (using javax.xml.transform facilities), but I wondered whether there is a more "groovy" way of doing this? I've tried using a the DomToGroovy class, which successfully create a groovy script version of the DOM document. But I'...

Grails g:if and string comparison

I've written some code that checks to see if the user is logged in as an admin or not to limit who can make changes to other user's permissions, but the if tag is never true. I've made sure the correct data is there by echoing it out but nothing I've found so far has given me a solution. <g:if test="${session.userPermissions == 'Admini...

Is Netbeans 6.7 incapable of debugging Groovy closures in a Grails application?

It seems to be possible to debug Grails applications in the recently released Netbeans 6.7, even if not directly through the menus. However, is it really so, that it's still not possible to set breakpoints in closures, as hinted in this thread? I'm currently quite baffled by this, since I find it hard to believe they still haven't imple...

Grails: retrieve bean from flow scope

Hi, In my Grails app, I have a bean stored in flow scope under a key that is dynamically generated. In a GSP I want to retrieve the bean. Assume that the key of the bean is the current Date as a String (though it's not really). If in my GSP I use something like ${new Date().getDateString()} then this will render the current date, bu...

Is there a .NET equivalent for Groovy and Grails or Ruby on Rails?

Recently I've been playing a bit with Groovy and Grails and I have to say I'm nothing but impressed by the simplicity and productivity this framework could offer. In the past I've also greeted the world via Ruby on Rails and what not, having that very same feeling so it's pretty much obvious that when it comes to web apps, DRY KISS is d...

scripting a Grails app

Hi, I need to write a script for a Grails application that modifies persistent data, send e-mails to users, etc. While there's nothing Grails-specific about this - I could accomplish these tasks using JDBC, JavaMail - I'm hoping there's a better way. Specifically, if I could write a Groovy script which has access to the Spring beans, a...

Grails behavior difference between run-app and run-war

I'm relatively new to Groovy and Grails and am trying them out in my spare time. I've got a small test Grails application that I'm able to run fine using grails run-app, but grails run-war results in an error. In the grails-app/conf/BootStrip.init method, I'm adding some property getters onto the DefaultGrailsControllerClass and Defaul...