groovy

Debugging GroovyWS. Get the actual generated XML

I'm using GroovyWS in a Grails app to connect to an external SOAP server. I'd like to see the actual XML that is generated by GroovyWS since I'm getting errors without any useful information. I know I can use wireshark or something similar, but there really should be an easier way. Printing the object just prints the Java Object@... s...

Validating date format inside a groovy controller

Hello, I have to validate the format of a date string coming from a csv file. I use the csvReader(au.com.bytecode.opencsv.CSVReader) parser. Below is the code I use to get the data from the csv reader and change it to a date format. def String strToDate = csvrow[monatVal] myDate = new Date().parse("dd.MM.yy HH:mm",strToDate) The pro...

Investing in Grails?

Today someone told me I should give Grails a try. So we can still use our old java code for some things, but develop much faster. This isn't really a debate on what programming language is better, although if you have tips I'm all ears, but really my question is: Is Grails just an overhyped fashionable thing to use, or is it here to st...

How to use existing java class from grails

Hi, how can I call a method residing in an existing Java class from Grails app ? Is it necessary/recommended to wrap that up in a service? ...

How to use Java or Groovy printf to add Thousands separator to String

In Java, I need to add a thousands separator to a decimal number formatted as a String. However, I do not want a millions or billions separator... just a thousands separator with the existing fractional part of the number preserved. 9 == 9 999.999 == 999.999 9,999 == 9999 999999,999.999 == 999999999.999 I do not strictly need to us...

insert hibernate domain objects to different database?

I want to copy all data of a specific table from database1 to database2. In my system i have access via hibernate to the domain object from database1, i don't have to transform the data-structure. i have only a native jdbc connection to database2. whats the best solution to make this groovy script very generally to support all kinds of...

Grails - Find by non-native types

I'm very new to grails (day 2). First, I find it hard to find easily browsable resources (the documentation is very raw, and the tutorials are spread out and only show 'hello world' types of examples ). I've set up my domain class with a relationship to other data types. class ShopCategoryPage{ //some stuff ProductProcedure procedure;...

using groovyxmlslurper from EL in JSP

I've been tasked with creating a JSP tag that will allow developers to pass a URI to an xml document, and have an object returned that can be navigated using EL. I have been using groovy and grails quite a bit so I thought of trying something like rval = new XmlSlurper().parseText(myXml); and throwing that into the request so that b...

Generate a list from another list transforming each element on Groovy

I've got the following code on a Controller def db = new Sql(dataSource) def rawLines = db.rows("SELECT name FROM LINES") def lines = [] /*(db.rows returns the values as [NAME:value] */ rawLines.each { lines.add(it.name) } /*Then, use lines */ I can't keep away the impression that there is probably ...

What is the full syntax of Groovy's GPath expressions?

While trying to parse RSS feeds in Groovy, I found a GPath example using wildcards: def text = """ <data> <common-tables> <table name="address"/> <table name="phone"/> </common-tables> <special-tables> <table name="person"/> </special-tables> <other-tables> <table name="business"/> </other-table...

Groovy: Escaping an arbitrary (unknown) regular expression

I want to split a string via String.split(k) where k is an arbitrary string (read from intput). The problem is that k can be any string and thus may include regular expression operators, such as: "*[". In such cases the split method fires an exception since the regular expression is not well formed. What I am looking for is a way to ...

Hows the syntax to getProperty dynamically?

Is this possible and if, how? item.foo = "moo" def x = "foo" item.[x] = "moo" ...

Tomcat, Groovy and clean urls

I'm trying to get Groovy running inside Tomcat with clean urls. Since my knowledge of Tomcat's url mapping and filters is quite limited, I'm running into a brick wall. What I'd like is to create a front-controller called index.groovy that handles all incoming requests. The problem is that I can't seem to figure out how to create the cor...

Access values of static closure in Groovy

Hello, I'd like to store some properties in a static closure and later access them during a method call: class Person { static someMap = { key1: "value1", key2: "value2" } } So how can I write a method within Person, which retrieves this stored data? Regards, Peter ...

Making Grails form development DRYer

Hi, When using Grails, the GSP code to render each form field looks something like this: <tr class="prop"> <td valign="top" class="name"><label for="username">Login Name:</label></td> <td valign="top" class="value ${hasErrors(bean: person, field: 'username', 'errors')}"> <input type="text" id="username" name="username" value="$...

Extend JackRabbit or build up from Lucene?

I've been working on a site idea the general concept is a full text search of documents that also allows user ratings based on these rating I wanted to boost the item's value in the Lucene index. But I'm trying to find if I should extend JackRabbit or just build from the Lucene base. Is there any good way to extend JackRabbit in this way...

Grails Hibernate H2 problem

hi, I have an application with two domain classes as follows: DomainA : PK, name DomainB : PK, FK (points to DomainA.PK), name. And when I try to list elements that belongs to DomainA using the DomainB.name as order factor, as follows: def listings DomainA.createCriteria().list(params) { PK{ order('name','asc') } }...

Grails - check if item has parent

I'm new to Grails, Groovy and GSP. I have a domain class "ProductCategory". class ProductCategory { static constraints = { } static mapping = { table 'product_category'; version false; cache usage: 'read-only'; columns { parent column: 'parentid'; procedure column: '...

MVC in Groovy/Grails

Hi, I'm newbie to groovy. How can we call domain methods from controller in Grails. Controller : def results = User.fetch_results User Domain : def fetch_results { def users = this.get(1) } Sorry if the above code is wrong, i need to know how to access domain methods from controller. thanks. ...

How do I check in files for building with git?

I'm using git to manage a grails project I have.I set up a git repository on a remote server and what I want to do is when I have code working locally, I want to commit it and push to the remote server. I want the updated groovy file and gsp's to be put into the right spot on the remote server so that grails will pick up the changes for ...