How would you go about this reflection task in Groovy:
(1) provide a class type to the Groovy function
(2) loop over all the methods of this class
(a) print out each parameter name and type from the method
(b) print out the return type
...
Does groovy support any kind of nested iterator notation?
In the example below, I want to somehow get the projectName value, that came from the outer iterator, into my inner iterator. Is this possible without storing in a variable? In my example I get a runtuime error that "project" is not found
it.myprojects.project.each{
println...
New clone from git repo, fresh install of groovy and grails. Seems to work for everyone else on my team? New to groovy and grails. Any help or general troubleshooting is appreciated.
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.g...
The problem in a nutshell:
This is what happens when trying to insert a row with a few null columns using a prepared statement and groovy.sql.Sql:
groovy:000> val
===> [123123123, 2, null, 0, 0, , null, , 1213020112511801, 1283425009158952, 1, 2, null, 0, 0, , null, , 1213020112511801, 1283425009158952]
groovy:000> destSql.execute "ins...
I have a command object in another package from my controller. I import it in the controller. I create and return an instance of this command from the create action:
def create = {
def reportCreateCommand = new ReportCreateCommand()
reportCreateCommand.name = params.name
reportCreateCommand.jrxmlFile = params.jrxmlFile
r...
To get around this I have to move such classes to src/groovy. It would be nice to have all of my domain model classes in the domains directory rather than split them up.
Update 1:
This is a popular (look for GRAILS-2515) requested feature on the Grails Jira page. If anyone is interested in this feature you can vote and track it here.
U...
Hey there,
I was trying to display a picture using regular HTML
I have this,
<img src="../../web-app/images/cargo.png" align="left"/>
Maybe I'm doing something wrong there backing up directories with the "../../"
But last time I checked that's how it was done
If there is a simpler and better way to do it via Groovy, or maybe CSS, I'...
I seem unable to use a Closure as a parameter to a superclass constructor when it is specified inline.
class Base {
def c
Base(c) {
this.c = c
}
void callMyClosure() {
c()
}
}
class Upper extends Base {
Upper() {
super( { println 'called' } )
}
}
u = new Upper()
u.callMyClosure()
The compilation fails wi...
I'm creating a Groovy client for a .net SOAP service that requires a soap header that looks like this:
<soap:Header>
<HeaderInfo xmlns="http://foo.bar.com/ns">
<token>abc-unique-token</token>
</HeaderInfo>
</soap:Header>
I found the faq for adding headers to CXF messages and it gets me almost there, but not quite. ...
I've a grails application service where I'm trying to call a stored procedure dynamically.
Here is a sample snipper of what I'm trying to do:
myService.callProcedure (procedureName, inputParams)
My stored procedure takes input and out params. How I can call a procedure on the fly without registering output parameters and then get all...
I have a sql file that creates a database in mysql:
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `mydb`...
I've created a desktop application using Groovy and SwingBuilder.
I would like to add sound effects to my app.
How can I do that ?
Thank you...
...
I've been having issues with testing my Grails application's authentication. It appears that the browser won't accept cookies, so I created a simple grails application as a test.
<html>
<head>
<title>Welcome to Grails</title>
</head>
<body>
<g:each in="${request.cookies}">
<h1>${it.name} = <span class="value">${it.value}<...
I am coding this with Groovy
I am currently trying to convert a string that I have to a date without having to do anything too tedious.
String theDate = "28/09/2010 16:02:43";
def newdate = new Date().parse("d/M/yyyy H:m:s", theDate)
Output:
Tue Aug 10 16:02:43 PST 2010
The above code works just fine, however when my string cha...
I used following code.
class Bike{
def manufacturer;
private getManufacturer(){
manufacturer
}
}
But I was able invoke getter method from another class.
...
There are several tutorials and even some posts here about shrinking .war files. However, the most common technique (to include grails.war.resources = {} in Config.groovy) does not seem to work for me. No matter what, grails dumps everything into the war file making a 25meg .war. Has this functionality changed? Grails 1.3.4
...
How can I use eval in groovy to evaluate the following String:
{key1=keyval, key2=[listitem1, listitem2], key3=keyval2}
All the list items and keyval is a String.
doing Eval.me("{key1=keyval, key2=[listitem1, listitem2], key3=keyval2}") is giving me the following error:
Ambiguous expression could be either a parameterless closure exp...
Hi
Coming from a Java background, learning Groovy seems a not-very-radical way to learn many concepts inherent to dynamic languages.
I am planning to start learning Groovy via
Unit testing my existing Java code with Groovy ( There are many articles on www for it, but what are the cons ? )
Automation Testing via Geb ( Using Spock wit...
I have to unit test a method of a groovy class which uses sleep() to delay processing in a loop.
Obviously I don't want my test suite to sleep really, so I tried to mock the sleep() call in my class:
MyClass.metaClass.sleep = { return }
I tried a few variations of this with no success.
Can someone tell me the correct way to mock thi...
A few years ago, I wrote a small LDAP gateway that processes LDAP requests from mail clients (Apple Mail, Thunderbird, SquirrelMail, etc) by looking up the results from a relational database. It's mainly used for email address auto-completion, but can also be used by address book software (e.g. Apple AddressBook).
The current soulution ...