I refactor my code and I am looking for a solution to grep my source files for something like
if ( user && user.name && user.name.length() < 128 ) ...
in order to replace it later with ruby's andand or groovy's ?. operator (safe navigation operator).
...
I'm implementing a program which utilizes Groovy as scripting engine offering users the possibility i.e. to automate tasks. Hence scripts have to be loaded on demand, which I achieve with the following code:
// short version, try/catch and error handling skipped
String[] roots = new String[] { "data" };
Binding binding = new Binding();
...
hi,
I am new to grails.I am doing web application that uploads the image from client side and it stores that in server.
My Gsp code is:
<g:uploadForm action="saveImage">
<input type="file" name="image">
<input type="submit" value="Submit">
</g:uploadForm>
My saveImage action in controller is:
def saveImage={
def file = request.get...
I'm using Grails to send a large number of HTML emails. I use the SimpleTemplateEngine to create my email bodies in this fashion:
def ccIdToEmailMap = [:]
def emailTemplateFile = Utilities.retrieveFile("email${File.separator}emailTemplate.gtpl")
def engine = new SimpleTemplateEngine()
def clientContacts = ClientContact.list()
for(...
Is there a way to override the location of the groovysh.profile / groovysh.rc file on the command line? e.g.
GROOVYSH_RC=one_time_groovysh_rc groovysh
Thanks.
...
I have to ship some groovy code to some users that have only java installed (no grooy, no $groovy_home, etc). I'm trying to invoke groovy from the commandline but I'm having no luck. Here's my bat file:
java -classpath .;lib;bin;bin-groovy introspector.AclCollector
And here's my exception:
Exception in thread "main" java.lang.NoClass...
I started dabbling in groovy yesterday. There's an example on the groovy website that I understand but I would like to know more about why it works the way it does. What's confusing me is who[1..-1]. Is this like saying who[1..who.length()-1]? I can't find any documentation on this syntax.
Are there any good groovy tutorials out ther...
I'm looking for a way to redirect output in a groovy script to stderr:
catch(Exception e) {
println "Want this to go to stderr"
}
...
The ProxyMetaClass and Iterceptor classes for intercepting arbitrary Groovy method calls is well documented. Is there also a way to intercept property accesses? When I try to do this by intercepting "getProperty", I still get the error message:
groovy.lang.MissingPropertyException: No such property: foo
...
Can someone tell me why this Grails domain class will not compile (at runtime)?
class Person {
String name
String getSomething(int i) {
}
}
I get this error when I run with grails run-app:
2008-12-27 15:26:33.955::WARN: Failed startup of context org.mortbay.jetty.webapp.WebAppContext@187e184{/asrs2,C:\Steve\asrs2/web-ap...
How can I reference a Groovy domain class from Java class using Eclipse?
I've put my domain class in package:
package com.me.myproject
public class Person {
String name
int age
}
Then in my Java class I attempt to reference com.me.myproject.Person. This works for grails run-app (command line) but not Eclipse. Eclipse can't re...
I did a grails clean and afterwards when I run via grails run-app the app never starts and the following is repeatedly displayed (goes on forever, stuck in some kind of loop).
I'm running Grails 1.0.4, Java 1.6 on Windows XP.
Grails is somehow stuck in an invalid configuration. Any idea how to restore it?
[groovyc] Compiling 3 sourc...
There is no new Groovy Unit Test built into NetBeans. And if I create one manually, I can't get it to run in NetBeans.
Is it not implemented, or is there something wrong with my installation?
...
Hello everyone,
I want to develop a web application (no frameworks) mixing java with groovy. I am using the IDE Netbeans with the plugin.
If I start a new Java SE project and add a groovy class, it works with no problems.. but when I create a new java EE project and add a groovy class it can't compile and shows me the following error:
...
I'm trying to mix-in a class in my Groovy/Grails app, and I'm using the syntax defined in the docs, but I keep getting an error.
I have a domain class that looks like this:
class Person {
mixin(ImagesMixin)
// ...
}
It compiles fine, but for some reason it won't work. The file containing ImagesMixin is located in my /src/groovy/...
There are essentially 2 places to define JavaScript functions in Grails, directly in a element on the GSP, and within a separate javascript source file under /web-app/js (for example, application.js). We have defined a commonly reused javascript function within application.js, but we also need to be able to generate parts of the functio...
I'm doing my first experiments with Grails and am looking for a way to have fields represented by a combobox (such as one-to-one domain associations and numbers with a narrow range constraint) to be optional, i.e. there should be an empty entry in the combobox.
How can this be achieved? I've tried both adding a nullable:true constraint ...
I'm developing a LoB application in Java after a long absence from the platform (having spent the last 8 years or so entrenched in Fortran, C, a smidgin of C++ and latterly .Net).
Java, the language, is not much changed from how I remember it. I like it's strengths and I can work around its weaknesses - the platform has grown and decidi...
Let's say I have a class called Store that has many Employees. My RESTful listXML method looks like this:
def listXML = {
render Store.list() as XML
}
And the result looks like this:
<stores>
<store id="1">
<name>My Store</name>
<employees>
<employee id="1" />
</employees>
</store>
</store>
My question is, how...
I have a "Set" that I need to use the findAll closure upon. The Set contains objects, not just primitive values. For instance... I have a Set of Employee objects and I need to iterate and grab elements of that Set of Empolyee Objects by attributes of the Employee.
For some reason the findAll closure seems to be just ignore my close and...