groovy

XmlSlurper/NekoHTML document fragment parsing - No HTML or BODY tags wanted

Dear All, I am trying to parse the following HTML fragment, and I would like to get the same fragment as output (without HTML and BODY tags). Is this possible? If so, how? Thank you Misha p.s. I am reading here: http://nekohtml.sourceforge.net/faq.html#fragments and I believe I have added the correct options below. However, the output ...

SOAPUI & Groovy Scripts, executing multiple SQL statements in one go

Hi, I've got some soapUI tests, that use groovy scripts to first insert some data into a table Previously, I've been using the following snippet of code to do this : def conn = context.dbConnEtopup conn.execute( "INSERT INTO A(ID, NAME) VALUES (1, "Johnny")" ) This works fine, however I have many test scripts that now d...

XmlSlurper NodeChild that represents a body tag?

Dear All: I would like to get a Groovy NodeChild that represents, e.g., a body tag. However, if I do html=new XmlSlurper().parseText(blah) I get html which is a NodeChild. However html.body is a NodeChildren tag, and I can't seem to get a NodeChild. Much help appreciated! Thank you Misha ...

Groovy pretty print XmlSlurper output from HTML?

Dear All: I am using several different versions to do this but all seem to result in this error: [Fatal Error] :1:171: The prefix "xmlns" cannot be bound to any namespace explicitly; neither can the namespace for "xmlns" be bound to any prefix explicitly. I load html as: // Load html file def fis=new FileInputStream("2.html") def htm...

How do I get all the calendar entries for a particular time range using Google Calendar API

I want to view events over specific time range for a specific calendar, but am having trouble using the API, It is a generic API, and it reminds me of using the DOM. The problem is that it seems difficult to work with because much of the information is in generic base classes. How do I get the events for a calendar using Groovy or Java...

How do I return an Array from grails / jdo to Flex

this seems really simple but I haven't gotten this to work. I am building my app with grails on google app engine. This pretty much requires you to use JDO. I am making an HTTP call from flex to my app. The action that I am calling on the grails end looks like so def returnShowsByDate = { def query = persistenceManager.newQuery( Sh...

Strange groovy behavior when dealing with threads

Dear All: I have an interesting dilemma. If I define my class as: class Browser { def swtException protected Object evaluate(script) throws SWTException { swtException=null display.syncExec() { try { result=swtBrowser.evaluate(script) } catch (SWTException swtException) { ...

How do I iterate over all lines of files passed on the commandline in Groovy?

Hi I want to read whole file contents in groovy on command line. I am using this code #!/usr/bin/env groovy def xmlData ="" System.in.withReader { xmlData=xmlData+ it.readLine() } println xmlData and the following command cat 1.xml | /root/a.groovy But it only reads one line from the file. I want to read whole f...

replace XmlSlurper tag with arbitrary XML

Dear All: I am trying to replace specific XmlSlurper tags with arbitrary XML strings. The best way I have managed to come up with to do this is: #!/usr/bin/env groovy import groovy.xml.StreamingMarkupBuilder def page=new XmlSlurper(new org.cyberneko.html.parsers.SAXParser()).parseText(""" <html> <head></head> <body> <one attr1='val1'...

Authentication problems between Groovy & CouchDB?

Hi all, fairly new to Groovy and I've been trying to write some test cases with Groovy for out REST interfaces. To setup our test fixture I needed to clearout the CouchDB databases and wrote a simple script to do this, but for some reason I keep getting Unauthorized messages back from CouchDB. Reduced the code down and still can't see wh...

How to add imports to groovysh on startup?

I'm working on a project where I'd like users to experiment with Java classes on Groovysh. I'd like to make it convenient for them and want to import certain packages by default, when groovysh starts up so that users would not have to re-type the same imports every time they start the shell. Does anyone know how to accomplish this? Than...

Add item to start of list

How can I use Groovy to add an item to the beginning of a list? ...

In Grails / Hibernate Can you set the generator to increment only if not assigned?

is there a way to have hibernate use auto generated ids if it wasn't assigned but use the assigned value if it was? ...

Considering moving from Java/Spring MVC to Grails

I'm currently using Java & Spring (MVC) to create a webapp, and I'm considering moving to Grails. I'd appreciate feedback/insight on the following: I have multiple application contexts in the current Java/Spring webapp that I load through the web.xml ContextLoaderListener; is it possible to have multiple application contexts in Grails?...

How to access controller dynamic properties within a base controller's constructor in Grails?

Basically, I want to be able to assign objects created within filters to members in a base controller from which every controller extends. Any possible way to do that? Here's how I tried, but haven't got to make it work. What I'm trying to achieve is to have all my controllers extend a base controller. The base controller's constructor...

Break from groovy each closure

Is it possible to "break" from a Groovy each Closure? Or should I be using a classic loop instead? ...

How to use Enum in grails (not in domain class)

Hello, i want to use Enum to represent some selection values. In /src/groovy folder, under the package com.test, I created the Enum. package com.test public enum TabSelectorEnum { A(1), B(2) private final int value public int value() {return value} } Now, I am trying to access it from controller like TabSelectorEnum.B.va...

Groovy + OSGi or Grails?

I have been learning OSGi and also a little about Groovy recently but am very new to both. I know Groovy is part of the Grails framework and that Grails is good for rapid development. One of the most desirable features in OSGi is class loader management and I believe this is probably still an issue with Grails (correct me if wrong). S...

Combine Hibernate class with @Bindable for SwingBuilder without Griffon?

Dear All: I have implemented a back-end for my application in Groovy/Gradle, and am now trying to implement a GUI. I am using Hibernate for my data storage (with HSQLDB) per http://groovy.codehaus.org/Using+Hibernate+with+Groovy (with Jasypt for encryption) and it is working quite well. I was wondering if there are any good tips for ...

org.hibernate.HibernateException: Error while accessing enum.values(): class com.mksoft.fbautomate.domain.Account$Type

This error is driving me nuts!!! Caused by: java.lang.NoSuchMethodException: com.mksoft.fbautomate.domain.Account$Type.values() The same exact class works fine in a separate Groovy file. Any ideas/help much appreciated. Most confusing... http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Enum.html has no values() method! Here is m...