Is it possible in grails to sort query results according to a property of a parent class in a relationship. E.g. I have a user domain class which has a one to many relationship with a list of Tasks.
When showing the list page of the Tasks domain class, I want to be able to sort the list of tasks by the associated User name.
class User ...
In a Service of a Grails project, I like to find, at run time, the arguments of Dynamic Methods in order to inform callers.
Also, I like to call the method and if doesn't exist to return an error,
I will appeciate any help.
...
Hello all,
I'm really brand new to Groovy and I'm trying to get something done. I've written some Groovy code (which works just fine) which receives some text. This text should be an integer (between 0 and 10). It may just happen a user enters something different. In that case I want to do some specific error handling.
Now I'm wonderin...
I'm implementing in Groovy a DSL for some existing file format.
In this format we have a construct like
group basic_test {
test vplan_testing {
dir: global_storage;
};
};
And here I have problem with this dir: global_storage - groovy considers "dir:" as a label, so I can't handle it.
Do you have an idea how I can rec...
I can't get static imports to work in Groovy. Is this supposed to work?
(I'm running Groovy 1.7.4 on Windows)
Constants.groovy:
package foo
class Constants {
static final PI = 3.14
}
Test.groovy:
package foo
import static foo.Constants.PI
class Test {
static main(args) {
println("pi=" + PI)
}
}
EDIT: Both fi...
how can i use pagenation with a controller in side show page of another controller
this is my code:
plan controller:
def show = {
if (!params.max) params.max = 4
if (!params.offset) params.offset = 0
def planInstance = Plan.get(params.id)
def planVoiceServiceListCount = PlanVoiceService.countByPlan(planInstance)
def planVo...
Hi, I have the following relationship between two domain classes:
class Emp {
String name
hasMany = [itemsell:Item, itembuy:Item]
}
class Item {
String name
}
And I need to know what items are common to both collections for a given Emp (itemsell and itembuy); how can I do such iteration?
Thanks
...
Is there any way to send a Soap envelope using Groovy
...
I have a code taht I am working on that was last worked on some time ago. It was an earlier version of grails (but I am not sure which) and I had to run the grails-upgrade command for it.
Now when I do grails run-app, i get the following:
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, General e...
This is weird: using groovy strings to hold some command lines for execution, I find that sometimes if there are quote characters inside the string, the execution simply silently fails.
WTF? (Updated, see below.)
Here's my test program:
print " 1: " ; "grep nameserver /etc/resolv.conf".execute().text.eachLine {println it } ...
def doc = """
<html>
<body>
<div tags="1">Test1</div>
<div taGs="">Test3</div>
<div TAGS="4">Test4</div>
</body>
</html>
"""
def html = new XmlSlurper().parseText(doc)
html.body.div.findAll { [email protected]()}.each { div ->
println div.text()
}
This code print only Test1! How ignore case for attribute @tags?
...
I have a multi-project build and in each of the projects I have several packages in the main src tree which need to be packaged up separately from the rest of the src as individual EJB artifacts:
com/foo/ejb/ejb1
com/foo/ejb/ejb2
...
There can be an arbitrary number of these EJBs in each project (0 or several).
My question is, how do ...
I'm looking to write a Java (Groovy actually) web application that will need to talk to both AWS and Eucalyptus clouds for both compute and storage. So we're looking for a Java library that can talk to both.
I know that Eucalyptus is supposed to be AWS API compatible so anything that talks to AWS should be able to talk to Eucalyptus bu...
In the example below (Taken from the Book of Geb), we're clicking on a button that takes us to another page.
class GoogleHomePage extends Page {
static url = "http://google.com"
static at = {
title == "Google"
}
static content = {
searchField { $("input[name=q]") }
searchButton(to: GoogleResult...
A sample script ss.groovy:
@Grab(group='org.codehaus.groovy.modules.http-builder',
module='http-builder',
version='0.5.0')
import groovyx.net.http.HTTPBuilder
println('done')
for some reason takes ~25 seconds to load when run with
groovy ss.groovy
and ~5 seconds when run with
groovy -Dgroovy.grape.autoDownload=fal...
Hi, I've been trying to do some xml modifications with groovy's XML Slurper.
Basically, i'm going through the xml and looking for tags or attributes that have ? as the value and then replacing it with some value.
I've got it working for xml that doesn't have namespaces but once I include them things get wonky. For example, this:
...
Hi guys, I have a gross looking function and am wanting to clean it up. All it contains is some maps, a for loop, and if statements.
Basically I have a map that I would like to grab only certain information from but one of the keys that I need from it changes by one number in each map.
I was thinking maybe a simple switch statement or...
In a groovy tutorial, I encountered the following code:
class DateTagLib {
def thisYear = {
out << Calendar.getInstance().get(Calendar.YEAR)
}
}
I don't know what the << means, and I'm having no luck with google.
Edit: I now know that << sometimes is a bit shift. But what does it mean here?
...
I am perl, python guy and new to java and groovy.
I am getting this error while running groovyConsole
groovy is working fine.
myhome:~/gscripts # groovyConsole
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAc...
I have a groovy file that is trying to call some methods from a Java class that I have set up using docx4j to parse .docx files
When I set up a pure java test program in eclipse, I am able to do this fine. However, when I have my .groovy file set up, I get no compilation errors, but at runtime I get this stack trace:
org.codehaus.groo...