I have a grails project with some additional java source files under src/java folder. When compiling/running the server, the files under that directory get compiled into the project's target folder, together with all other groovy/grails classes. So far so good.
However, when I try to load one of the java source files (from src/java) usi...
I have a new netbeans maven/groovy project, and I actually prefer to mix my java and groovy files in src/main/java and src/test/java (I find it easier to navigate this way and my pom reflects this configuration). However, when I have my project setup this way in Netbeans 6.8, it always shows the generated-sources folder in error. The stu...
Hi, it's my first time using webflows in Grails and I can't seem to solve this.
I have 3 domain classes with associations that look something like this:
class A {
...
static hasMany = [ b : B ]
...
}
class B {
...
static belongsTo = [ a : A ]
static hasMany = [ c : C ]
...
}
class C {
...
static belongsTo = [ b : B ...
I want to switch from Java to a scripting language for the Math based modules in my app. This is due to the readability, and functional limitations of mathy Java.
For e.g, in Java I have this:
BigDecimal x = new BigDecimal("1.1");
BigDecimal y = new BigDecimal("1.1");
BigDecimal z = x.multiply(y.exp(new BigDecimal("2"));
As you can s...
I have just completed an evaluation of Java, Groovy and Scala.
The factors I considered were: readability, precision
The factors I would like to know: performance, ease of integration
I needed a BigDecimal level of precision.
Here are my results:
Java
void someOp()
{
BigDecimal del_theta_1 = toDec(6);
BigDecimal del_theta_2...
I can't seem to make eachLine skip the first line, according to this there is an integer argument that can be passed to eachLine but I can't figure out the syntax
http://groovy.codehaus.org/groovy-jdk/java/io/File.html#eachLine(int,%20groovy.lang.Closure)
#doesn't work
new FileReader('myfile.txt').eachLine firstLine=2,{
line-> p...
What I want to do is invoke maven from a groovy script. The groovy script in question is used as a maven wrapper to build J2EE projects by downloading a tag and invoking maven on what was downloaded. How should I accomplish invoking maven to build/package the EAR (the groovy script is already capable of downloading the tag from SCM).
...
Hi,
I have a javascript function (very big one!) that I need its functionality in a Java (Groovy) class. It is a simple calendar converter. I can rewrite it in groovy but just want to know if it is possible to call javascript function from a java (groovy) method? I guess functional testing libraries like selenium and Canoo should have ...
hey
i have the following domain model:
class Location {
String name
static hasMany = [locations:Location, persons:Person]
}
class Person {
String name
}
so basically each location can hold a bunch of people + "sub-locations".
what is the best way to recursively query for all persons under a location (including it's sub l...
I am currently working with User objects -- each of which have many Goal objects. The Goal objects are not User specific, that is, Users can share the same Goal. I am attempting to fashion a way to calculate a "similarity percentage" between two Users... (i.e., taking into account how many Goals they share as well as how many Goals they ...
Hi,
I am working on a GWT application which uses GWT-RPC.
I just made a test groovlet to see if it worked, but ran into some problems
here's my groovlet
package groovy.servlet;
print "testing the groovlet";
Every tutorial said we don't need to subclass anything, and just a simple script would act as a servlet.
my web.xml looks like...
I'm not even sure about how to title this qn. But, hope there is an easy way to do it in dynamic language like groovy.
say I have a class Service, where I delegate the business logic. the methods in it are
funA(), funB()... funX().
Now I have a controller class, where I call the service closure, which can be invoked like service.funA(...
My goal is to write this:
println "this should be 3: ($1+2)" //this is invalid groovy, it won't run
Yet this is valid in ruby. Is there a way I can put statements that will eval inside a string or must I use complete variables names? I am basically looking for the Ruby equivalent of:
puts "this shoud be 3: #{1+2}" #this is valid ruby...
I am writing a DelegatingMetaClass that I would like to apply to all groovy classes in my project, but I do not how to get hold of all classes in the project?
Here is the code:
/*
This will work ok, since I know Foo beforehand, but what about classes
that do not exist yet?
*/
def myMetaClass = new DelegatingMetaClass(Foo.class)
...
I'm writing a program which needs to traverse a set of directories. Tried to use the following code:
file.eachDirMatch(/.*[^.svn]/){
//some code here
}
But that ended up match none of my directories. I realize this boils down figuring out the right regex hang head in shame but even after revisiting some Java Regular Express...
Hi, this is actually connected to an earlier question of mine here.
Anyway, I have 3 domains that look like this:
class A {
...
static hasMany = [ b : B ]
...
}
class B {
...
static belongsTo = [ a : A ]
static hasMany = [ c : C ]
...
}
class C {
...
static belongsTo = [ b : B ]
...
}
In my GSP page, I call an a...
I wrote logic for testing urls using threads.
This works good for less number of urls and failing with more than 400 urls to check .
class URL extends Thread{
def valid
def url
URL( url ) {
this.url = url
}
void run() {
try {
def connection = url.toURL().openConnection()
connection.setConnectTimeout(10000)...
Has anyone had any experience with Spring transactions (class-level, with proxy, annotation-driven) not getting started in a Groovy Class? I've been struggling with an unexplained LazyInitialization exception noticed that stacktrace does not include a call to start the transaction. Sounds crazy but I have to wonder whether Groovy picks u...
I have a number of test cases using groovy.
I want to be able to have the test case fail but to carry on with the rest of the script. Tried using:
testRunner.fail( "It didn't work" )
also tried
assert false : "It didn't work"
but they both abort the test case even if the abort on error is unchecked.
Any ideas?
...
Grails offers the ability to automatically create and bind domain objects to a hasMany List, as described in the grails user guide.
So, for example, if my domain object "Author" has a List of many "Book" objects, I could create and bind these using the following markup (from the user guide):
<g:textField name="books[0].title" value="...