Fixing GrailsUI infamous 'Cannot create a menubar within a menu'

I personally like/use GrailsUI a lot and I'm sorry that it's been discontinued. Just today while I was upgrading an app from Grails 1.1 to 1.3.6 I found out that my previously working menubar is now spitting out ugly errors (like this one).

The problem lies in the unsafe use of instance variables by the tag library.

Luckily for us the solution is pretty simple, just replace all references to items and group with a request scope variable like request.items and request.group. In my case I went a little further and tried to come up with a variable name that would not clsh with other variables actually used by me.

My (working, yup) copy of the menu tag library is available at https://gist.github.com/1358135.
To use it just copy it into your project's taglib folder and then build a menubar as you would do with GrailsUI, only using the g: prefix instead of gui:.

Popular posts

A not so short guide to ZFS on Linux

Indexing Apache access logs with ELK (Elasticsearch+Logstash+Kibana)

Mirth: recover space when mirthdb grows out of control