Search |
||
Hello Grails!Posted by bleonard on January 30, 2008 at 6:37 PM PST
NetBeans 6.1 M1 was just released, and with it comes rudimentary support for the Groovy language and the Grails framework. I say rudimentary because this is M1, but there's a lot of work in progress as you can see from this task list. So, of course I'm anxious to compare Grails to Rails. What better way to do than by creating the same blog application I've been blogging about with Rails? Setting Things UpUnlike with Rails, the NetBeans Groovy plugin does not come bundled with Groovy and the Grails framework - these must be pre-installed on your system (don't worry, it's easy):
Creating the Grails Project
Creating the ModelOr as Grails prefers to call them, Domain classes.
Creating the Controller
Run the Application
Adding Another FieldOur blog needs a body field.
A Friendlier Database ConfigurationSurprisingly, we haven't had to talk about databases yet as the Grails framework magically took care of this for us. The Grails framework includes HSQLDB and all of the necessary configuration was setup for us in DataSource.groovy, which you'll find under the Configuration node:
Do the following:
Validating InputLike Rails, validation in Grails is very straightforward.
Customizing the ViewOkay, enough with this dynamic scaffolding. Let's generate our controller and view code. Unfortunately, for this step I haven't found the menu option in NetBeans yet, so we'll resort to the command line for now.
<h1>The Groovy Blog</h1>
<g:each in="${postList}" var="post">
<h2>${post.title}</h2>
<p>${post.body}</p>
<small><g:link action="show" id="${post.id}">permalink</g:link></small>
<hr>
</g:each>
The Completed Application»
Related Topics >>
Netbeans Comments
Comments are listed in date ascending order (oldest first)
Submitted by shemnon on Wed, 2008-03-12 08:23.
Wheres the plugin for 6.1 Beta?
Submitted by bleonard on Thu, 2008-03-13 08:48.
Yes, I was wondering that as well. I installed the development updated center into the Beta (Tools > Plugins > Settings > Add). Here's the URL: http://deadlock.netbeans.org/hudson/job/javadoc-nbms/lastSuccessfulBuild... . It appears to be working fine - I can't vouch for any of the other plugins on that site :-). /Brian
Submitted by bleonard on Fri, 2008-02-01 11:22.
Tim, by chance have you used development builds of NetBeans in the past? If so, it would be a good idea to delete your user directory (~/.netbeans/dev). After doing so you'll need to install the Groovy and Grails plugin again. I'm also on OS X 10.4 so it should work for you. -Brian
Submitted by timyates on Fri, 2008-02-01 11:47.
Yeah, I've tried removing my entire ~/.netbeans folder, but still no joy... I'll try it again, it's probably me being an idiot...
Submitted by jeremygerrits on Fri, 2008-02-01 12:06.
Tim, I had the same problem with 6.1M1 for WinXP. Try the latest build (I installed todays) and it should work just fine.
Submitted by timyates on Fri, 2008-02-01 12:12.
Got it :-) I needed the "All" install, not just the Java SE one... Something must be missing from Java SE that the Groovy stuff requires :-) As you were people... ;-)
Submitted by bleonard on Fri, 2008-02-01 13:52.
Tim, good catch. The issue's being tracked here in case you want to watch it. -Brian
Submitted by reichertdf on Thu, 2009-06-04 09:05.
I apologize if this isn't an appropriate question. In the create.gsp, the data entry boxes are a standard width. I can't find a place to edit this width to sizes that fit the data field length. Can you help with this or suggest a more appropriate place to ask the question?
Thanks
Submitted by reichertdf on Thu, 2009-06-04 14:07.
Ah, I finally sorted through the CSS that controls the data entry forms. Sorry for the clutter.
Submitted by hsalameh on Thu, 2008-01-31 10:54.
Why is installing Groovy needed? Doesn't Grails include Groovy already?
Submitted by hsalameh on Thu, 2008-01-31 11:10.
In other words, is step 1 under "Setting Things Up" really needed?
What i did was download only Grails(which should already include Groovy), and then for what you have done under step 5, i set both home directories to the location of the grails installation, but all what i got was a lot of exceptions when trying to use the grails actions in NB. Is what I did incorrect?
Submitted by bleonard on Thu, 2008-01-31 12:59.
Yes, Grails does include Groovy already, but like you, I couldn't get it to work w/out also installing Groovy separately. NetBeans may be dependant on something additional that ships with Groovy. A better place for this question would probably be the scripting e-mail alias.
Submitted by aaron_broad on Fri, 2008-02-01 00:53.
Hi,
I have a couple problems. #1 Runnin ghte application stops at "Running Grails application..". No server is available at port 8080 and the web browser does not launch. Manually executing the command from the windows console works.
Once I have the server running with the scaffolding. Should edit and delete work? Both result in a Error 404 for me. Is that default behaviour for editing not to work right away with a scaffold or is my grails broken?
Thanks,
Aaron Broad
Submitted by bvaessen on Fri, 2008-02-01 01:28.
These steps don't work for me. Installing went fine, but when creating the domain class, I receive the following error message: java.lang.IllegalArgumentException: Called DataObject.find on null. I cannot seem to find a way to get around this. I already started over with a fresh userdir, but keep getting this error.
Submitted by bleonard on Fri, 2008-02-01 09:28.
Hi Aaron. For problem #1, typically that occurred for me when there was some kind of build error, but if the app runs okay from the command line, I don't know what's going on. For problem #2, interesting find - edit and delete do not work for me either until I generate the view code. This appears to be because the Domain Class and Controller are named differently. I just filed this as an issue with Grails. /Brian
Submitted by bleonard on Fri, 2008-02-01 09:32.
Ben, are you able to successfully run the command "grails create-domain-class Post" from the command line (make sure you're in the project directory). -Brian
Submitted by timyates on Fri, 2008-02-01 09:48.
Doesn't work for me :-( I install M1, and it works fine... Then install the Groovy plugin, and it won't start up again
Netbeans throws the followingjava.lang.NoSuchMethodError: org.netbeans.Stamps.getModulesJARs()Lorg/netbeans/Stamps;
Submitted by bvaessen on Wed, 2008-02-06 01:04.
Brian, Sorry for my late response. I just tried to create the Domain Class from the command line, so this works.
Submitted by bvaessen on Wed, 2008-02-06 03:20.
Brian, I have done some extra tries and found out that when I create my project on my D:-drive (in Windows) the error occurs. I tried to create it on my C:-drive as well and then the error does not occur. Seems like a bug to me...
Submitted by schmidtm on Mon, 2008-02-25 04:56.
Hi *,
the problem with having grails and the project on different drives is fixed, see:
http://www.netbeans.org/issues/show_bug.cgi?id=127531
Please file all issues within issuezilla (category groovy) and give feedback what's missing.
|
||
|
|