Friday, November 11, 2011

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 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
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:.

1 comment:

Anonymous said...

This is a good blog message, I will keep the post in my mind. If you can add more video and pictures can be much better. Because they help much clear understanding. :) thanks Cavalieri.