I am working on a grails app where in development mode, I log some calculations to a log file through log4j.
I want to provide a service which will read the log file and make its contents available to a developer so they can see what is being logged in the log file.
Is there a way I can get the log4j appender file name at run time?
...
Hi,
Does anyone know the java or groovy equivalent of a python for loop using izip?
python example:
for item_one, item_two in izip(list_one, list_two):
I'd like to do the same in java or groovy
Thanks
...
I have an application that I am working on modifying and I am having a problem and not sure where to look.
When I first started trying to compile the problem, some of the groovy files had imports that were not resolving correctly. After some tracking down, I see that the package was not defined the way the groovy files were expecting. S...
I am trying to process RSS feed using Google Reader API, but the issue is that even if feed encoding is UTF-8 it is returned in an unreadable format.
resp.contentType = "text/xml"
resp.characterEncoding = "UTF-8"
URL url = new URL("http://www.google.com/reader/public/atom/feed/" + rss);
BufferedReader reader = new BufferedReader(new I...
Hi everyone,
I have a list of checkboxes like this:
<g:each in="${mylist}" var = "item" >
<tr>
<td colspan="2"><g:checkBox value="${dimension.id}" name="${item.id}"/> - ${item.name}</td>
</tr>
</g:each>
I have to alter it so I get 2 columns in each row (2 checkboxes per row)
<g:each in="${mylist}" var = "item" >
<...
For now I have field "String firstName" it converted to "first_name" and i want "firstname" as default in Hibernate. Is it posible?
...
Hi,
I have this GSP:
<g:uploadForm name="myForm" action='save'>
<input type='file' name='documentFile' value=''/>
<input type='file' name='documentFile' value=''/>
<input type='file' name='documentFile' value=''/>
<input type='file' name='documentFile' value=''/>
<input type='submit' value='Submit'/>
</g:uploadF...
I have a grails project and a java project. The java project was a standalone set of POJO classes, and I just dumped them into src/java under my grails project.
In the controller, I added an import statement for this package.
Now when I do a grails run-app and try to run the program, I get a grails runtime exception. It is saying NoCla...
I'm implementing a few math classes and for the first time finding problems with Java (cumbersome and duplicated code) that I really can't overcome by cleaver coding. Operator overloading would be REALLY handy, and there are a few other things that Groovy can do a lot better (I may also try Scala at some point).
So I'm still writing th...
Hi,
This is OK
def variables=[
['var1':'test1'],
['var2':'test2'],
['var3':'test3']
]
println "${variables.size()}"
variables.each{entry ->
println "${entry} "
}
I got:
3
[var1:test1]
[var2:test2]
[var3:test3]
but this caused problems
def variables=[
...
I'm trying to test my grails app using integration test that makes http requests. Actually it's a selenium/tellurium test, but it doesn't matter. But as i see when i running grails tests it doesn't starts web container, the same time i see many examples in blog articles that people tests grails app using selenium and other test tools tha...
Is there a way to grab the key of one map and replace the value of the other with its value?
def wild = [animal1:"pet3", animal2:"dog", animal3:"pig"]
def pet = [pet1:"hamster", pet2:"fish", pet3:"cat"]
if(pet.containsKey(wild.animal1)) {
//replace wild.animal1 with the value contained in pet3 for example
//so wild.animal1 wou...
I was wondering if there is any neat way to write new line into the file from Groovy. I have the following script:
new File("out.txt").withWriter{ writer ->
for(line in 0..100) {
writer << "$line"
}
}
I could use writer << "$line\n" or writer.println("$line"), but I was wondring if there is any way to use << operat...
I have a couple of domain classes defined, Employee and EmployeeDesiredSkill,
Employee has
static hasMany = [employeeSkill:EmployeeDesiredSkill]
and EmployeeDesiredSkill has
static belongsTo = [employee:Employee]
Yet groovyc is giving me a bunch of errors like the following:
[groovyc] Compiling 15 source files to C:\dev\JavaTes...
I can mock calls to:
MyDomainClass.createCriteria().list{
eq('id',id)
eq('anotherParameter',anotherParameterId)
}
with:
def myCriteria = [
list : {Closure cls -> returnThisObject}
]
MyDomainClass.metaClass.static.createCriteria = { myCriteria }
as advised at:
http://davistechyinfo.blogspot.com/2010/01/mocking-hibernat...
Is there a way to print Ivy output when using Groovy Grape.
when I use Grape, it's just hanging there till finishes downloading all dependencies. I would like to know what it's happening and what it's downloading.
Thanks,
...
Hello,
I am trying to run some unit tests for my grails app, via "grails test-app -unit". This works as expected.
However, when the tests are done, junitreport takes way too long to generate the HTML results, eg:
[junitreport] Transform time: 33294ms
33 seconds (on top of the rest of the time) is ridiculous when I want to rapidly mak...
Hello,
Lets say I have two domain classes:
class User {
String name
Role role
}
class Role {
String name
static belongsTo = [user: User]
}
and I create some records:
def r1 = new Role(name: "role1").save()
def r2 = new Role(name: "role2").save()
new User(name: "user1", role: r1).save()
new User(name: "user2", role: r2).save...
I defined an annotation as follows
import java.lang.annotation.ElementType
import java.lang.annotation.Inherited
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target
/**
* Annotation for any object that exposed a remote interface
*/
@Target({ElementType.TYPE})
@Retention(...
I have my java code running.
I added a groovy shell to evaluate the main groovy file.
What it does is simple.
GroovyShell.run (main.groovy)
Now, in my main.groovy, if I have other .groovy files I'd like to "require", how can I do that?
Is there something like "require, source, load, require_one, import" filename?
...