Wednesday, August 26, 2009

Another way to include version property in your JSON

For those want to include domain class version property in JSON, you can get help from GRAILS-4530: Chaning your grails version or Using the way provided by Sigi(See the description).
But I found another way to get that. Instead of using a new DomainClassMarshaller, I just retrieve the DomainClassMarshaller from the ConverterConfiguration. Here is my code:
import org.codehaus.groovy.grails.web.converters.configuration.ConvertersConfigurationHolder as CCH
import org.codehaus.groovy.grails.web.converters.marshaller.json.DomainClassMarshaller as DCM
import grails.converters.JSON

class BootStrap {

def init = { servletContext ->

def cfg= CCH.getConverterConfiguration(JSON.class)
def marshellers= cfg.orderedObjectMarshallers
for(m in marshellers){
if(DCM.class.isAssignableFrom(m.class)){
m.includeVersion= true
break
}
}
}
def destroy = {
}
}
Maybe it is not as simple as Sigi's solution, but I think it is the complement to this issue.

Monday, August 24, 2009

A new Grails powered site launched

A new Grails powered site launched last Friday: GroovyLive, which is a simple groovy console with a simple tutorial.
Here are features of this simple Grails App:
  • Hosted on Google's GAE
  • Script history
  • Supporting hotkey. You can find these keys though the tooptips of the buttons of console.
  • A simple Groovy tutorial, although not including Groovy MOP.
  • The tutorial is intractive. You can try the script included in tutorial in a command shell, and the content will be the next chapter when the result of that script matches the answer.
It is powerd by:
Since English is not my native language, if there are some error in my tutorial, pls point it to me.
Thanks.