groovy

Grails Dependency Injection Problem

Hi, I am having problems when using dependency injection with Services in Grails. class ExampleService{ def example2Service def example3Service def method1(){ def result = example2Service.method2() } } class ExampleService{ def example3Service def method2(){ def result = example3Service.metho...

Is there an option for toggle watchpoint in debug perspective on STS 2.5.0 RC1 for Grails?

Heres is what I'm currently looking (sample project from a Grails book): http://yfrog.com/f/ekkapp/ I’m trying to use STS 2.5.0 RC1. On the sample app that I’m working on to learn Grails, I’m getting some unexpected results on the UI. I’m passing in the user, and I’m not getting redirected to the Todo List. So, in the action method I w...

Detecting first and last item inside a Groovy each{} closure

I am using Groovy's handy MarkupBuilder to build an HTML page from various source data. One thing I am struggling to do nicely is build an HTML table and apply different style classes to the first and last rows. This is probably best illustrated with an example... table() { thead() { tr(){ th('class':'l name', 'name') ...

How to avoid saying "gstring"?

I am picking up Groovy. The language is fine. But I have a non-technical problem. One of the classes is called GString. In some context, it can be misleading. And mentioning it is not very appropriate in the office, especially when some non-technical female colleagues are around. I guess this is not enough to justify renaming the class ...

How to parse a Sharepoint Date from Hex to a java.util.Date

Hello, I'm trying to parse a Date from a MS Sharepoint into a java.util.Date. The Details: I query a Sharepoint from a Grails webapp via the SOAP GetListItems method. In the Sharepoint list, the date is displayed correctly, here 09/11/2009 but in the SOAP response, I get 0x01ca60cf|0x94894000 Further, this only happens with docx, pptx,...

Grails: How to make everything I create Upper Case?

Hello, I am currently using CSS to change everything I write to upperCase when I create an entry, but that is not enough. When I save things, the text shown in the text fields is upper case, but the real value that Grails stores stays in lower case. I am assuming I'd need to change something in the controller or anything. Maybe transf...

Groovy, Grape and HtmlUnit

Hi folks! could someone instruct me how to Grape-include HtmlUnit in a Groovy (1.7.5) script so that it actually works? Here's what I'm doing: @Grapes([ @Grab('net.sourceforge.htmlunit:htmlunit:2.8'), @GrabExclude('xml-apis:xml-apis') ]) import com.gargoylesoftware.htmlunit.* def client = new WebClient(BrowserVersion.FIREFOX_2...

Booleans in grails aren't persisted?

Hello, I'm developing a small application on Grails 1.3.5 and I run into this very strange problem. My domain classes feature some boolean typed fields. None of these fields is persisted when creating a new instance (and saving it of course). For example, I have this domain class "Employee", defined as follows (simplified): class Emp...

Grails: GET a large dataset and POST a significant amount of params (best method)

I need to GET a large collection in a form, and POST a large selection of user ids from the collection to a controller. Q Whats the best way to load a large collection and submit a large amount of params. Break down:(Getting) there might quite a number to choose from so I wouldn't want to load the complete collection incase memory prob...

How to do method aliasing in groovy?

Hi, I am trying to redefine dynamic methods of a domain in groovy. Is there something similar alias method in ruby in groovy? ...

[SOAPUI] Sorting arrays in Groovy

Hi all, I'm trying to compare two arrays in groovy. My attempts so far have yielded a mixed response and therefore I'm turning to the collective for advice. In the following code I'm taking 2 REST responses, parsing them and placing everything under the Invoice node into an array. I then further qualify my array so I have a list of Inv...

How can I insert an xml comment with Groovy MarkupBuilder?

I would like to insert comments into my xml document with a Groovy MarkupBuilder. How is it possible? ...

How to return http 500 with soapUI

I am mocking my web service using soapUI. Now, I also want to test fault. For this, the mock service (=soapUI) should return a HTTP 500. Does anyone know, how soapUI can do this? thanks ...

Are groovy variables null-initialized, or is this an IntelliJ bug?

IntelliJ highlights the 'foo' variable in gray, and says "assignment is not used". What I want to know is - it is right or not... If this were java and not groovy, I know it wouldn't be right. public class Foo { public Foo() { Foo foo = null; // this 'foo' instance is gray ("assignment not used") try { foo = new F...

Groovy List all properties for class

I'm trying to list the properties (i.e. all properties that have a getter method) using Groovy. I can do this using myObj.properties.each { k,v -> println v} and that works fine. But, that also prints for the entire superclass hierarchy as well. If I just want to list the properties for the current class (and not the super class), is tha...

[Groovy] Searching for the contents of an Array in another array

Hi folks, I'm using groovy in SOAPUI and am currently trying establish whether the response from 2 endpoints yields the same results. I'm converting my XML response into an array for each endpoint and then looping through Array1 and then Array2 to confirm the presence of each item in Array1. This is very ugly code and I did look at m...

Determine if the month is almost over in Groovy

I am trying to figure out the best way to determine if a given Date is 10 days or less from the end of the month. I am basically building functionality that will display a message if the month is almost over. Thanks! ...

Groovy htmlunit

I'm having issues importing htmlunit (htmlunit.sf.net) into a groovy script. I'm currently just using the example script that was on the web and it gives me unable to resolve class com.gargoylesoftware.htmlunit.WebClient The script is: import com.gargoylesoftware.htmlunit.WebClient client = new WebClient() html = client.getPage('htt...

How do you override a method for a java type instance with Groovy meta programming?

Hi, I am trying to override the functionality of a method of a java type instance in my Groovy code but I am getting a classcast exception. I looked at the guide posted here but I can not get it to work. Since my actual problem is a bit of mess, below is some runnable example code that fails with the same error. In the example I wa...

Tool to send email from a DB

We are developing a webapp that needs to send out emails written in Java/Groovy. Currently, we are persisting each email to a database before we call the Java Mail APIs to send the mail to our SMTP server. I want to send out email asynchronously. I want to persist the email and then have another process pick up the email and send it (...