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}" />
<input class="save" type="submit" value="Save produ...
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)
{
println "current line: ${line}"
println "next line...
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 = something)
on rowid = something;
So I want to rea...
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..
...
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 set the LaF at, say, the Frame level?
(Sp...
Hi.
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
@Persistent(valueStrategy = IdGenerator...
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 object hierarchy to talk to the gui and h...
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?
...
I'm working on some GUI code in Groovy using SwingBuilder.
One of the elements on the screen is a JTable that's being used, essentially, as a properties editor. Groovy in Action has a fantastic example of how to do a display-only table, with what amounts to a side note that you can also attach a write closure. GiA's example is pretty ...
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 either on the file system or in the database.
...
How can I call a native shell script from a Groovy / Grails Application?
The shell script resides on the same machine.
...
Hi,
Nowadays I hear a lot about "Groovy on Grails" and I want to know about:
What is Groovy ?
What is Grails ?
What kinds of Application are built using Groovy on Grails ?
Thanks.
...
Hi,
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' birthDate='12-09-1983'/>
</players>
So my ques...
I plan to embed groovy in my application and use GroovyShell programatically - I will run the same script with different parameters several times with different parameters.
Does GroovyShell caches the compiled script or does it work only as a stateless interpreter?
...
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 any way to "pass through" the Maven goal to ...
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 this as a chance to play around 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?
...
Hi,
Are there any good code analysis tools available for Groovy? I'm looking for something similar to FindBugs, PMD, CheckStyle, etc. I may even be able to use some of these tools directly if they work on Java byte code rather than source code. A feature that would be particularly useful is the ability to identify obsolete code, though ...
Hi,
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(exportXmlFile) << mb.bind {
mkp.xmlDeclaration()
out <...
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
chops in our programming challenge....