Все вопросы: [groovy]

432 вопросов

2
голосов
3ответов
9324 просмотров

Firefox has detected that the server is redirecting the request for this address in a way that will never complete

I'm following Scott Davis' tutorials on developing grails apps, but whenever i try to run my app (or indeed his source code) i get "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." Safari gives a similar error message as does O...

1
голосов
1ответов
841 просмотров

groovy ant task

I'm using the groovy ant task to compile my groovy files, but it seems like groovy locks the jar file so it can't be moved, deleted, signed, etc. Has anyone run into this bug before and have a workaround? Seems weird that if I run the groovy ant task and compile to a jar file that groovy doesn't ...

0
голосов
1ответов
1301 просмотров

Cannot render form tag using 'render' in Grails Controller

Using markup with the render is not adding the form tag. I tried this with contentType "text/html", "txt/xml" and it does not work. I have this in my controller: def myTest= { render(contentType: "text/plain") { div(id:"myDiv") { p "somess text inside the div" ...

0
голосов
2ответов
2733 просмотров

searching backwards with regex

I have the following different texts line1: SELECT column1, line2: column2, line3: RTRIM(LTRIM(blah1)) || ' ' || RTRIM(LTRIM(blah3)), line4: RTRIM(LTRIM(blah3)) || ' ' || RTRIM(LTRIM(some1)) outColumn, line5: RTRIM(LTRIM(blah3)) || ' ' || RTRIM(LTRIM(some1)) something, line6: somelast Followin...

1
голосов
2ответов
483 просмотров

Can I run grails 1.2-M3 with groovy 1.7 beta 1?

I have groovy 1.7 beta 1 in my path and GROOVY_HOME pointing to same groovy 1.7 beta 1 directory. I have installed grails 1.2-M3, and set GRAILS_HOME to point to grails 1.2-M3. I would like to try some groovy 1.7 features in my grails app, anonymous inner classes to be precise. I am receiving a...

6
голосов
2ответов
25154 просмотров

groovy list indexOf

If I have a list with following elements list[0] = "blach blah blah" list[1] = "SELECT something" list[2] = "some more text" list[3] = "some more text" How can I find the index of where the string starts with SELECT. I can do list.indexOf("SELECT something"); But this is a dynamic list. SEL...

2
голосов
1ответов
1319 просмотров

groovy mocks with abstract methods

I have a Java object called Parameter and I'm trying to mock it using groovy. Parameter is an abstract class with 1 abstract method. It also has a non-abstract method called getName(). I'm trying to mock it as follows in Groovy: def p1 = [name:{"p1Name"}] as Parameter But I get a runtime erro...

41
голосов
6ответов
16154 просмотров

In groovy, is there a way to check if an object has a given method?

Assuming that I have an object someObj of indeterminate type, I'd like to do something like: def value = someObj.someMethod() Where there's no guarantee that 'someObj' implements the someMethod() method, and if it doesn't, just return null. Is there anything like that in Groovy, or do I need ...

2
голосов
1ответов
880 просмотров

Is the method groovy.xml.XmlUtil.serialize buggy for big xml input streaming?

When I execute the following script: mb = new groovy.xml.StreamingMarkupBuilder() mb.encoding = "UTF-8" xmlClosure = {...} //BIG XML File building (at least 300 KB) new OutputStreamWriter(new FileOutputStream(exportXmlFile), 'utf-8') << groovy.xml.XmlUtil.serialize(mb.bind(xmlClosure)) ...

14
голосов
5ответов
13938 просмотров

How to redirect output from Groovy script?

I wonder if there is any way I could change the default output (System.out) for the groovy script that I'm executing from my Java code. Here is the Java code: public void exec(File file, OutputStream output) throws Exception { GroovyShell shell = new GroovyShell(); shell.evaluate(file);...

6
голосов
6ответов
7629 просмотров

Triple single quote strings in Groovy - Should the resulting string contain extra spaces?

If I use the following groovy code: description: '''Join the Perl programmers of the Pork Producers of America as we hone our skills and ham it up a bit. You can show off your programming chops while trying to win a year's supply of pork ...

0
голосов
1ответов
4362 просмотров

How to convert XML file in UTF-8 using Groovy builder StreamingMarkupBuilder

Even if the question subject seems complicated, the issue is quite simple. I create an XML file with the following script: def xmlFile = new File("file-${System.currentTimeMillis()}.xml") mb = new groovy.xml.StreamingMarkupBuilder() mb.encoding = "UTF-8" new FileWriter(xmlFile) << mb.bind...

1
голосов
1ответов
62 просмотров

Is there a case for conducting unit tests (and integration or regression if applicable) with Groovy?

Is it just hype about testing Java classes with Groovy rather than using Mockito, Easymock etc? What's your experience and ease of application?

0
голосов
2ответов
648 просмотров

Java marketshare: what version of Java runtime do most people have? Do I need to use Flash to get 90% possible marketshare?

My friend and I are planning to build a simple chat client to let people in a (physical, real world) room chat with each other (people chatting over the same wifi network, possibly pinging some external server to organize things by the external IP address of the wifi network). Partly we planned t...

7
голосов
2ответов
1029 просмотров

Maven + Grails + App Engine

Has anyone used Maven, Grails, and App Engine together? I can use Maven with Grails and Grails with App Engine, but using them in concert gives me the following error: The command 'grails run-app' is not supported with AppEngine. Use 'grails app-engine' to start the application Is there an...

2
голосов
1ответов
1141 просмотров

Does GroovyShell cache the compiled scripts?

I plan to embed groovy in my application and use GroovyShell programatically - I will run the same script several times with different parameters. Does GroovyShell caches the compiled script or does it work only as a stateless interpreter?

1
голосов
1ответов
5682 просмотров

Import XML into a Grails Domain Class

I am reading an XML file with a schema based on a Domain Class. Here is a simple example for illustration (my current situation concerns a lot of fields from a lot of classes) : class Player { String name Date birthDate } The XML file to read is : <players> <player name='P1' bi...

100
голосов
4ответов
79814 просмотров

What are "Groovy" and "Grails" and what kinds of applications are built using them?

Nowadays I hear a lot about "Groovy on Grails" and I want to know more about it: What is Groovy? What is Grails? What kind of applications are built using Groovy on Grails?

11
голосов
2ответов
12751 просмотров

Calling a shell script from a Groovy/Grails Application

How can I call a native shell script from a Groovy / Grails Application? The shell script resides on the same machine.

1
голосов
2ответов
1151 просмотров

What are the pros and cons of using GroovyClassLoader vs. GroovyShell

I need to run some external code from my Java application that will be updated frequently and orthogonally to the rest of the application. As I do not to re-deploy the entire application for every code change (and for other reasons as well) we chose to use groovy for this code, and store it eithe...

2
голосов
1ответов
119 просмотров

Reading InBox With Grails/Groovy?

DO I need to inject the JavaMail Objects into the application context and access my inbox the old fashion way or is there some "magic" in grails to handle it for me?

3
голосов
3ответов
3144 просмотров

Can I just hand groovy's markupbuilder a node list?

I'm doing some XML processing with groovy. Specifically, I'm inhaling an XML file via XMLParser, doing a whole batch of in-memory processing, and then serializing the resulting data back out to XML via a MarkupBuiler. The vast majority of the data in the file gets transferred to a non-xml based...

1
голосов
2ответов
1131 просмотров

One-to-Many relationship. Select objects from datastore

I've omitted some code(package declarations, imports, other fields) for shortness. I have here simple One-to-Many relation. It worked fine till this moment. @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") class Restaurant implements Serializable { @PrimaryKey @...

0
голосов
1ответов
672 просмотров

Can groovy's swingbuilder get more than one look and feel in a Java swing application?

Via this question, it would seem that normally you can't mix-and-match look and feels in the same swing app. However, we've been using groovy's swingbuilder to handle all of our GUI code, and groovy seems to do enough black magic that this seemed in the Realms of the Possible. Can swingbuilder ...

3
голосов
3ответов
3281 просмотров

how to run stored procedure from groovy that returns multiple resultsets

I couldnt find any good example of doing this online. Can someone please show how to run a stored procedure (that returns multiple resultsets) from groovy? Basically I am just trying to determine how many resultsets the stored procedure returns..

2
голосов
2ответов
8189 просмотров

How to read a snippet from a file using groovy?

I am reading a file in groovy using this simple sample code file.eachLine {line-> // do something with line } For example my file has some data like this blah blah blah This is some more lines more lines Insert into something (x1,x2,x3) (Select * from some table where something = someth...

0
голосов
1ответов
1525 просмотров

groovy closure variable increment

If i am reading each line of a file like the following file.eachLine {line-> println line } is it possible to read the NEXT line inside the closure. for example file.eachLine {line -> //print next line as well if current line contains 'hooray' if (line.find(/hooray/)!=null) { print...

1
голосов
1ответов
3032 просмотров

How to configure and retrieve the value from a g:select in Grails?

I have a g:select in my view that displays a list of products: <g:form name="addproductform" action="saveProductToInventory" method="post"> <g:select from="${products}" name="product" value="${it?.id}" /> <g:hiddenField name="inventory.id" value="${inventoryInstance.id}" /...

0
голосов
3ответов
508 просмотров

Grabbing a string using regex

I have the following string. I have broken it into two lines below for clarity but they are one line. WHEN NVL(somevar1, 0) > 0 THEN (CAST(NVL(somevar2, 0) AS FLOAT(53)) / CAST(NVL(somevar3, 0) AS FLOAT(53))) * 100 I want to write a Regex so that I can get somevar1, somevar2 and some...

31
голосов
2ответов
28516 просмотров

Groovy property iteration

In the Groovy code below I replace the values of the feck, arse, drink properties of an instance of Foo with those of an instance of Foo2 class Foo { def feck = "fe" def arse = "ar" def drink = "dr" } class Foo2 { def feck = "fe2" def arse = "ar2" def drink = "dr2" ...