tiistai 29. maaliskuuta 2011

Getting & setting cookies in Grails

Setting:


import javax.servlet.http.Cookie
def c = new Cookie(someName, someValue)
c.maxAge = someNumberInSeconds
response.addCookie(c)

Getting:


request.cookies.each { println "${it.name} == ${it.value} }

perjantai 25. maaliskuuta 2011

ERROR errors.GrailsExceptionResolver - No signature of method: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.g

If you get this exception when trying to read uploaded files, you know you're missing enctype="multipart/form-data" from the form tag.


2011-03-25 09:45:25,798 [http-8080-2] ERROR errors.GrailsExceptionResolver - No signature of method: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [file]
Possible solutions: getXML(), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON(), getHeader(java.lang.String)
groovy.lang.MissingMethodException: No signature of method: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [file]
Possible solutions: getXML(), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON(), getHeader(java.lang.String)
at check.ProductScreenBinaryController$_closure7.doCall(check.ProductScreenBinaryController:85)
at check.ProductScreenBinaryController$_closure7.doCall(check.ProductScreenBinaryController)
at java.lang.Thread.run(Thread.java:680)

keskiviikko 9. maaliskuuta 2011

Deep JSON conversion woes

Need to do deep JSON conversion? Use this:

JSON.use("deep") {
def converter = results as JSON
converter.prettyPrint = true
render converter.toString()
}

If you get the Misplaced key -error, add the following line to Config.groovy:
grails.converters.json.circular.reference.behaviour = "INSERT_NULL"

tiistai 8. maaliskuuta 2011

ls colors in OSX

Just a quick tip, or more a reminder for myself: to get nice colors for ls, set the following environment variables in the shell conf file:

export CLICOLOR=1
export LSCOLORS=Exfxcxdxbxegedabagacad