November 16, 2009

Create New Grails Files in NetBeans

To add a new file to our Grails application in NetBeans we simply select File | New (Ctrl+N in Windows) while we have a Grails application open. NetBeans opens a new dialog and if we select the Groovy node we get a list of Grails filetypes we can select. NetBeans provides templates for these types or uses the Grails commands to create a new file to get a good start. For most filetypes we only have to specify the name and package, but for more general filetypes we can also define the location in the Grails directory structure.

We can also right-click on a node in our Grails application in the Project window. NetBeans has a context-sentive pop-up menu and if we select New... we see the most relevant Grails types for that node at the top. So if we right-click on the Domain Classes node we get the Grails Domain Class... option at the top.