Hello,
i've got a word document saved in xml format. In this document, there are some GString Tag like $name.
In my groovy code, i load the xml file to replace this GString tag like this:
def file = new File ('myDocInXml.xml')
def name = 'myName'
file.eachLine { line ->
println line
}
But it doesn't works. The G...
I am maintaining a Grails application that I did not write(I have no experience with Groovy/Grails, actually :)) and it currently has a bug on one of the environments it's deployed on, but not others.
In order to debug this, I want to jump into the grails shell on the affected server, run the command that I suspect is error-prone, and s...
I have a simple badly behaved server (written in Groovy)
ServerSocket ss = new ServerSocket(8889);
Socket s = ss.accept()
Thread.sleep(1000000)
And a client who I want to have timeout (since the server is not consuming it's input)
Socket s = new Socket("192.168.0.106", 8889)
s.setSoTimeout(100);
s.getOutputStream.write( new byte[100...
I have a project using Gradle as the build tool and I have to make use of the Java ant task. One of the sub elements in this task is a reference to a classpath and I would like to use refid. The build script uses Gradle's WAR plugin. Since the compile task works without any problem I know that the classpath is set up correctly:
depende...
The test class below verifies that a simple HttpService gets content from a given URL. Both the implementations shown make the test pass, though one is clearly wrong because it constructs the URL with an incorrect argument.
To avoid this and correctly specify the behaviour I want, I'd like to verify that in the use block of the test ca...
I am currently using sql.row("statement") and storing to a list. I then am trying to setup my xml file using MarkupBuilder. Is there a better way than iterating over the list poping off an item and then parsing it to add my different column names and values?
What is stored by list entry is
ID='X' Period='Yearly' Lengh='test'
So the ...
Hi,
I'm unsure about when exactly I need to use the spread-dot operator. If I have a list such as:
def animals = ['ant', 'buffalo', 'canary', 'dog']
Because both animals and the members of the list have a size() method, then in order to have the method invoked on the elements of the list (rather than the list itself), I need to use:
...
Hi,
Is there any way to pass model data to a view state? Consider the following example view state:
class BookController {
def shoppingCartFlow = {
showProducts {
on("checkout").to "enterPersonalDetails"
on("continueShopping").to "displayCatalogue"
}
}
}
If I want to pass the data model [products: Product.list...
I'm at school and we are doing this java stuff. We use a special library named sum.kern: http://www.mg-werl.de/sum/bjw.zip
I want to use Groovy instead of Java. But I can't get groovy to use this library. If I add the jar in grape and try to import sum.kern and create a sum.kern.Bildschirm it says that it is not able to find it. How to ...
Current code:
row.column.each(){column ->
println column.attributes()['name']
println column.value()
}
Column is a Node that has single attribute and a single value. I am parsing an xml to input create insert statements into access. Is there a groovy way to create the following structured statement:
Insert INTO...
I am currently trying to go back through and write unit tests for some code that wraps an existing class. The function I am looking for has code that looks like the following...
private OldObject oldObject
...
public Boolean method(){
Boolean returnValue = false
if(oldObject.method(100)){
returnValue = true
}
if(oldObject....
I'm trying to use the taglib call there's attribute parameters, but also the stuff inside the tag itself which the link taglib uses. I can't find the attribute to pass in to a g.link() call to have it render the text of the link. I've tried 'body' and 'link' and 'text' and 'linkText' already - none of those work.
I'm expecting to be ...
I have a situation where some of my groovy code references my java files, but I also have different java files that reference the same groovy code. When trying to compile in maven, I either need to compile the groovy before or after the java, and that won't really work since the groovy code depends on some java files, and different java ...
I'm having a hard time figuring this validation problem. I have one parent domain class defined as follows:
class Person {
String fullName
List telephones = []
static hasMany = [telephones : Telephone]
static constraints = {
fullName(size:3..50, blank:false, nullable:false)
}
}
Then a sublcass:
class Sal...
Consider the following usages of the Grails/GORM dynamic finder method findAllBy*:
def foo1 = Foo.findAllByYear(yyyy)
def foo2 = Foo.findAllByMonth(mm)
def foo3 = Foo.findAllByDay(dd)
def foo4 = Foo.findAllByYearAndMonth(yyyy, mm)
def foo5 = Foo.findAllByYearAndDay(yyyy, dd)
def foo6 = Foo.findAllByYearAndMonthAndDay(yyyy, mm, dd)
prin...
I'm writing my first Groovy API for a RESTful web service. Could someone please provide some good open-source examples or best-practices to inspire my API design?
I'm considering using Groovy's Expandos, XML Parsing, and straight-forward URL request mechanism, but I'd like to hear other ways to make an API Groovy. Ideas?
Thanks a bunc...
Whenever I execute the gmaven plugin, I get the following problem
org.apache.maven.lifecycle.LifecycleExecutionException: Internal error in the plugin manager executing goal 'org.codehaus.groovy.maven:gmaven-plugin:1.0-rc-5:generateStubs': Mojo execution failed.
The relevant section of my POM is below. Any thoughts why?
<plugin>
...
I recently configured groovy 1.6 (w/Java 6) into my ant build.xml script, so that it compiles everything through groovy, with the embedded javac command:
<target name="build-project" depends="init">
<groovyc destdir="antbin" classpathref="CIMS.classpath">
<src path="src"/>
<src path="test"/>
<classpath refid=...
What is best/good book to learn REST ? Same time looking good REST framework in java or groovy.
...
I have an Eclipse project with many unit tests written in Groovy. I can run the tests in each individual class using Eclipse's GUnit run configuration. I open this configuration, select the "Run a single test" radio button, and select the class whose tests I want to run. This works fine, however I want to run all of the tests in the the ...