Hi guys,
I'm trying to run a Groovy app to manipulate Excel files on STS (by SpringSource) 2.3.0.
My Groovy version is 1.7.
Class:
package com.mytool
import org.codehaus.groovy.scriptom.ActiveXObject
/**
* @author Mulone
*
*/
class SurveyTool {
static main(args) {
print 'test'
def wshell = new ActiveXObject(...
I have to calculate a "total" for each user based on individual actions -- that is, a User hasMany Actions and each Action has a point. So I need to basically get a sum of all the points on all the actions.
Actions are added and subtracted regularly. Since this can be a rather heavy operation, it's not feasible that I execute the "tota...
Hi,
I am quite new with Grails and now I have a problem while using NodeBuilder and GPath. Here is the code snippet
def builder = new NodeBuilder()
def menu = builder.menu {
header(title: "header 1") {
submenu(title: "submenu 1.1")
submenu(title: "submenu 1.2")
}
header(title: "header 2")
}
menu.grep {
pri...
Just started learning Groovy, got the PragProg book "Programming Groovy" and had a problem compiling one of the sample scripts:
class GCar2 {
final miles = 0
def getMiles() {
println "getMiles called"
miles
}
def drive(dist) {
if (dist > 0) {
miles += dist
}
}
}
def car = new GCar2()
println "Miles: $...
I'm trying to create a DSL that can easily use a dom node. Using DOMCategory is nice, but adds the noise of 'use(DOMCategory)'. Is there a way to avoid that?
I tried wrapping the script call inside a call to 'use', but this doesn't seem to work in closures.
...
def foo(map, name) {
println(map)
}
foo("bar", hi: "bye")
will print
[hi:bye]
Now I have a previous map that I wish to pass along to foo. In pseudo code, something like:
def otherMap = [hi: "world"]
foo("bar", hi: "bye", otherMap*)
So that it prints
[hi:world]
This doesn't work of course.
Also, trying to pass just the map...
Hi
I want to find out whether a variable is an array or not
if (params.writtenLines == ???)
much appreicated.
...
I have a short groovy algorithm for assigning rankings to food based on their rating. This can be run in the groovy console. The code works perfectly, but I'm wondering if there is a more Groovy or functional way of writing the code. Thinking it would be nice to get rid of the previousItem and rank local variables if possible.
def fo...
I've successsfully created ActiveXObject under development on Netbeans.
import org.codehaus.groovy.scriptom.ActiveXObject
def sas = new ActiveXObject("SAS.Application")
however, when I deployed the app to tomcat, i got the following message:
com.jacob.com.ComFailException: Can't co-create object
at com.jacob.com.Dispatc...
I am not able to get the Groovy MarkupBuilder to work with soapUI. I am very new to Groovy and I am just following one of the user guides on creating XML.
Testing a very simple method:
public String Example(){
def writer = new StringWriter()
def root = new MarkupBuilder(writer)
root.mkp.xmlDeclaration(version:"1.0", encoding:"UTF-8")
r...
I have two applications each pointing to a different database. when I deploy these applications to Tomcat at the same time, whichever datasource gets loaded first is the same datasource that gets used for both apps. I am using the latest Tomcat and Grails.
...
I am trying to create a multi line string in Groovy. I have a list of strings that I'd like to loop through within the multi line string. I am not sure what the syntax is for this. Something like below...
def html = """\
<ul>
<li>$awaiting.each { it.toPermalink()}</li>
</ul>
"""
...
I want to branch if a message-property-code does exist or not.
<g:if test="${message(code: 'default.code.foo')}">
true
</g:if><g:else>
false
</g:else>
should answer true if there a message property named default.code.foo and false if not.
It fails because it answers the code if there is no property for it.
...
Using Java, you can get the list of ISO2 codes through Locale.getISOCountries() (see this related question http://stackoverflow.com/questions/712231/best-way-to-get-a-list-of-countries-in-java).
However, I would like to have the list of all country names (in English for example) and not the list of ISO2 country codes. How can I do that ...
Essentially I am looking to have a url query parameter persist throughout the life of the grails application (POST or GET). ex.
http://localhost:8080/demo/controller/action/?myParam=foobar
I have tried a couple routes. Dynamic method overriding redirect and customizing application tags for createLink. However, since I also use grails ...
hi,
this might be trivial (please forgive me for that)
but my eventual goal is to have a string like
def newline= 'C:\\www\web-app\StudyReports\\test.bat'
but my old line only have one '\',
i tried different ways of using the following
def newline=oldline.replaceAll(/\\/,'//')
but did not work at ...
could someone help me out.
...
Dear All:
I am reading here:
http://groovy.codehaus.org/modules/http-builder/doc/get.html
I seem to be able to get
i) XMLSlurper output as parsed by NekoHTML using:
def http = new HTTPBuilder('http://www.google.com')
def html = http.get( path : '/search', query : [q:'Groovy'] )
ii) Raw text using:
http.get( path : '/search',
...
How do I setup logging in a grails unit-test?
When I try log.info or log.debug, the .txt output files are empty, even after I tried adding a console appender. What's going on here?
...
I'm trying to have ImageMagick run from grails to convert some images when I run the command to make an image nothing happens. I get no errors, no information returned nothing at all. I've tried running other commands like touch and ps ux just to see if they work and they all work fine. It just seems like the imagemagick commands are get...
Hi,
I'm trying to create separate controllers for admin in my application. So far I've got something like this :
"/admin/article/$action?/$id?"(controller:"adminArticle")
"/admin/comment/$action?/$id?"(controller:"adminComment")
And so on for all the admin controllers. I would like to make it simpler, tried :
"/admin/$controller?/$a...