Hello, guys.
I`m trying to dynamically represent the changes of coordinates of a groovy domain object via Google Maps API. The object has fields:
Double lat
Double lng
and a method:
void flyTo(lat, lng){
Thread.start(){
while (locked){
changeCoords (this)
this.save()
}
}
and here is a JS to repopulate changes to ...
Lets say I have the following one-to-many relationship:
Site has many Users
User belongs to one Site
I've setup the relationship like this
class Site {
static hasMany = [users:User]
...
}
and
class User {
static belongsTo = [site:Site]
int number
String username
...
}
Basically I want to update the userna...
I'm trying to take advantage of the fact that groovy is more dynamic than java.
I'd like to have a block of code that does
TypeA type = //do something to build an object
TypeA dbType = TypeA.findBySomethingAndSomething(something, somethingelse)
if(dbType != null)
type.id = dbType.id
type.save()
but that can work for multiple object...
Grails 1.1 onwards has 'encodeAsMD5' available on Strings -- is there a way to provide a salt for the function?
Typical usage:
${myString.encodeAsMD5()}
Another option would be to use the Apache DigestUtils class.
I'm not using this to do password hashing -- instead, I'm using it for a verification mechanism to determine when a requ...
I'm trying to create my own CRUD controller in grails for the stuff that the scaffolding won't do.
Instead of maintaining code for a controller for each domain, I'd like to have one controller that can look after any domain for the generic CRUD calls.. as the only difference is the domain class name.
Using the example of domain class J...
Is it possible to set cookies on response when the return render type is set as json?
I can set cookies on the response object when returning with a standard render type and later on, I'm able to get it back on the subsequent request. However, if I were to set the cookies while rendering the return values as json, I can't seem to get ba...
I'm using grails to build an application that functions primarily as a service framework. My question is: Can services be secured in the same fashion as controllers?
uri-based example:
class SecurityFilters {
def filters = {
all(uri: "/**") {
before = {
// Ignore direct views (e.g. the default main index page).
...
I have a filter setup to get executed for all actions and it is executed once per request unless ajax get request is sent to the server. When it's an ajax get request, the filter gets executed twice but I see the browser sending only one request to the server. Is there a way to get the filter to fire only once per request?
Here's how m...
Hey all,
As per the top two answers here I'm trying to compile a mixed Java 6 + Groovy project with Maven, using the GMaven-plugin from org.codehaus.gmaven. Up untill yesterday we were using the old 1.6.0 version of Groovy (never changed it after we finally got it working), but since 1.7.0 is now stable I thought we'd switch to that.
...
AST Transformations are implemented in Groovy. What's a practical example of using an AST Transformation?
...
I have the following classes:
class Catalog {
static mapping = {
id composite:['name', 'manufacturer']
columns {
name column:'cat_name'
manufacturer column:'manuf_id'
}
}
String name
Manufacturer manufacturer
}
class Order {
static mapping = {
columns {
// How to rename foreign keys as cat_n...
Might be just me, but I have a hard time understanding how to secure just some of the pages in a Grails application with the Shiro Plugin.
I use this in my security filter:
class SecurityFilters {
def filters = {
all(uri: "/**") {
before = {
// Ignore direct views (e.g. the default main index page).
if (!con...
as a tcl developer starting with groovy, I am a little bit surprised about the list and map support in groovy. Maybe I am missing something here.
I am used to convert between strings, lists and arrays/maps in tcl on the fly. In tcl, something like
"['a':2,'b':4]".each {key, value -> println key + " " + value}
would be possible, where...
I'm part of a group that starts a new development project from scratch.
Currently it is on hobby-basis but we aim to make it our living
in the time frame of 1-2 years.
We are senior developers coming from a multitude of languages and techniques
with much of the focus on Java for the last few years.
Now, we're thinking of choice of tools...
I am using the Eastwood chart plugin (0.5) for Grails (which also requires the google chart plugin). I have a line graph and it's all working brilliantly, but I am struggling to find much information on the plugin and the different things it can do other than what's in the example gsp file.
does anyone know how I can get the area und...
I am creating an invoice management application using Grails, and am experiencing problems with inheritance.
If is my intention that each invoice should contain a collection of lines/items, and that when the invoice is formatted for printing, the items are sorted by date, separated into lists by category, then have the price of each lin...
I'm trying to use groovy's MockFor and proxyDelegateInstance to mock a java class with constructor parameters, but I can't seem to get it right. My Java class looks like:
class MyJavaClass {
private MyObject myObj
public MyJavaClass(MyObject myObj) {
this.myObj = myObj;
}
}
class MyGroovyTest {
@Test
void testMyJ...
In the code presented here: Gant file, there is the following code:
target(dist: 'Create release artefacts') {
depends(test)
depends(jar)
}
target(run: 'Run the distributed jar') {
depends(dist)
Ant.java(jar: distributedJarPath, fork: 'true')
}
target(hello: 'Hello World') {
println("Hello World"...
Is there a way to querying across 2 databases in grails ?
Example (I made a select on two databases - works and test) :
select
c.crf_name,
c.crf_id,
ig.group_id,
ig.group_name,
from
works.crfs c,
test.item_groups ig;
1) I would like to query again...
I'm using the following lines of code to call the web-service below:
def wsdl = 'http://somewhere.com/services/msgService?wsdl'
proxy = new WSClient(wsdl, this.class.classLoader)
proxy.initialize()
def msg = proxy.create("com.somwhere.test.api.MsgService")
msg.applicationName = "APP1"
msg.clientId = 5
msg.additionalPro...