HOWTO: Building Your First Grails Application

Discussions

News: HOWTO: Building Your First Grails Application

  1. HOWTO: Building Your First Grails Application (24 messages)

    Build Your First Grails Application [fixed link] is a great tutorial produced by Scott Davis, the first in a series of articles planned on this topic. This article is an introduction to the Grails framework, how to install it, and how to build a simple application: a trip planner. Future installments in the series will expand this sample application.
    Rails was (and still is) worthy of the accolades and adoration it has received, but it presents Java developers with difficult choices. Do you abandon the familiar Java platform for the promise of a new one? And what do you do with your existing Java code, your existing production servers, and your staff of seasoned Java developers? ... Groovy wouldn't be nearly as appealing to Java developers if it forced them to rewrite entire applications from the ground up to take advantage of it. Happily, Groovy seamlessly integrates with your existing codebase. Groovy doesn't replace the Java language -- it's an enhancement. You can quickly pick up Groovy because at the end of the day, Groovy code is Java code. The two languages are so compatible that you can rename a working .java file to a .groovy file -- for example, change Person.java to Person.groovy -- to have a perfectly valid (and executable) Groovy file (albeit one that doesn't take advantage of any of the syntactic sugar Groovy provides). This deep level of compatibility between Groovy and the Java language means that Grails doesn't need to reinvent the wheel when it comes to the key technologies used behind the scenes. Instead, it allows you to look at familiar Java libraries through Groovy-colored glasses. JUnit TestCases are wrapped in Groovy and presented as GroovyTestCases. Grails offers a new twist on Ant builds with GANT, a pure-Groovy implementation of Ant. Grails wraps Hibernate in a thin Groovy facade and calls it GORM -- the Grails Object/Relational Mapper. These are just three examples of how Grails allows you to leverage all of your existing Java experience while taking advantage of modern Web development practices.
    Java developers and architects now consider technologies such as Grails as potential additions to the enterprise tool set. This tutorial shows how to build a Grails application and how to leverage existing Java know-how and resources.

    Threaded Messages (24)

  2. Love the recursive link. William
  3. I started to use Grails last week and love it. I started to review various frameworks like Ruby On Rails, CakePHP, Smarty Template Engine for PHP, Wicket, etc.. and out of that list I found Ruby on Rails to be the most productive, until I found Grails. Why Grails and not JRuby on Rails? Grails has very nice integration for Hibernate and Spring out of the box. This shows you how far convention over configuration can save you hours alone. Grails provides a lot of what Rails does plus more. Filters, *EASY* tag libraries, *EASY* custom taglibs, nice AJAX support, look and feel support via SiteMesh, support for Java (Thanks to Groovy :) and much more. I didn't just read articles on each of the frameworks I mentioned above, I created several applications. Most recently a Blogging application that is very much like JRoller.com. Only thing I didn't work on yet was the customize themes and advanced Admin interface. I strongly recommend you to look at Grails and even go as far as comparing it to Rails and other frameworks. I'm sick of wasting a day on setting up a basic application in J2EE. Best Regards, Richard L. Burton
  4. JEE setup ?[ Go to top ]

    I'm sick of wasting a day on setting up a basic application in J2EE.

    Best Regards,
    Richard L. Burton
    Sounds like Grails is worth a try - might even be fun. I'm curious, though - why does it take you a day to set up a basic JEE application ? If we're talking about a Web app with JSF, EJB, and Hibernate support it takes me about five minutes using WebLogic Workshop, which is far from the simplest IDE out there. Just wondering what people are using for JEE tools - ?
  5. Re: JEE setup ?[ Go to top ]

    I'm sick of wasting a day on setting up a basic application in J2EE.

    Best Regards,
    Richard L. Burton


    Sounds like Grails is worth a try - might even be fun.

    I'm curious, though - why does it take you a day to set up a basic JEE application ? If we're talking about a Web app with JSF, EJB, and Hibernate support it takes me about five minutes using WebLogic Workshop, which is far from the simplest IDE out there. Just wondering what people are using for JEE tools - ?
    also, with maven 2 and its archetype capability, it can take just a few seconds to create a decent JEE project.
  6. errr... can the link to get updated???
  7. Here is the link http://www.ibm.com/developerworks/java/library/j-grails01158/
  8. This deep level of compatibility between Groovy and the Java language means that Grails doesn't need to reinvent the wheel when it comes to the key technologies used behind the scenes.
    More precisely, Grails re-used existing Java technologies rather than implementing its own. JRuby gives almost the same level of Java compatibility (save for some differences in paradigm & obvious syntax style) but when you're talking about Rails, much of it is built from the ground-up in (J)Ruby. In addition to re-using Hibernate and Ant, most of the DI is handled by Spring, and all of Grails' web presentation is underpinned by Spring MVC. Granted, Grails puts a much prettier face on it. But the key is, everything you've used in Java, and the time you've spent learning Spring and Hibernate are immediately applicable to the Grails environment.
  9. Questions[ Go to top ]

    I was playing around with Grails for the past couple of days. It is really nice. But a few questions came to my mind. First how popular it is? is Grails getting attention and adoption from big companies and organizations? How big its community is? and how fast it is growing? Wasn't it better to use component-based view framework (like wicket or click) rather than MVC?
  10. Re: Questions[ Go to top ]

    I was playing around with Grails for the past couple of days. It is really nice.

    But a few questions came to my mind.

    First how popular it is? is Grails getting attention and adoption from big companies and organizations?

    How big its community is? and how fast it is growing?

    Wasn't it better to use component-based view framework (like wicket or click) rather than MVC?
    To answer your questions: popularity - Grails has a rapidly growing community with over 1.6 million lines of user contributed code in the plugin repository (http://grails.org/Plugins) and the highest traffic mailing list amongst these frameworks: http://www.nabble.com/Web-Development-Framework-f16257.html enterprise - SAP are using Grails for their new product (https://www.sdn.sap.com/irj/sdn/wiki?path=/display/Community/Composition+on+Grails&), Oracle has show their past commitment (http://www.infoworld.com/article/06/05/11/78223_Hnoraclejavaone_1.html) and Groovy in general is being adopted fast (http://glaforge.free.fr/weblog/index.php?itemid=227) component based frameworks - Grails is mainly action based on the MVC sde, but also it can't really be compared to Wicket or other component based frameworks because it is a full stack framework attempting to solve everything from the project structure, to the build system, to the ORM layer and through the plugin system things like messaging, job scheduling etc. You could of course use Wicket backed onto Grails if you wanted component based features
  11. Re: Questions[ Go to top ]

    Grails has the highest traffic mailing list amongst these frameworks: http://www.nabble.com/Web-Development-Framework-f16257.html
    It would be interesting to see Struts, Flex and GWT's numbers compared. I'm willing to bet Grails would still do well, but it probably wouldn't be #1. Also, since Spring (or Seam) doesn't use a mailing list for most developers questions, their numbers are not a good reflection of real traffic. From Open Source Web Frameworks' Mailing List Traffic - June 2007:
    The thing I find the most interesting is Eelco's thoughts [about mailing list traffic] in July 2005:
    ...who says having a list that has a lot of traffic is a good thing? It might just as well be an indication of a too-hard-to-understand framework having insufficient documentation.
    ;-)
  12. Re: Questions[ Go to top ]

    The thing I find the most interesting is Eelco's thoughts [about mailing list traffic] in July 2005:
    ...who says having a list that has a lot of traffic is a good thing? It might just as well be an indication of a too-hard-to-understand framework having insufficient documentation.
    Indeed. My point in my rant there was that numbers alone don't tell you much, and numbers are not a good reason to pick a framework. Of course, you want to know whether the community around an open source project is viable, so that you can count on some continuity for a while, but if you ask me, that's about as far as you should take the numbers, whether it comes to list traffic, downloads (popularity) or 'adoption by large companies' (an argument I regularly see mentioned, but which is something probably not a single soul on this planet can reliably answer to start with).
  13. Re: Questions[ Go to top ]

    Grails has the highest traffic mailing list amongst these frameworks: http://www.nabble.com/Web-Development-Framework-f16257.html
    It would be interesting to see Struts, Flex and GWT's numbers compared. I'm willing to bet Grails would still do well, but it probably wouldn't be #1.

    Also, since Spring (or Seam) doesn't use a mailing list for most developers questions, their numbers are not a good reflection of real traffic.

    From Open Source Web Frameworks' Mailing List Traffic - June 2007:

    The thing I find the most interesting is Eelco's thoughts [about mailing list traffic] in July 2005:
    ...who says having a list that has a lot of traffic is a good thing? It might just as well be an indication of a too-hard-to-understand framework having insufficient documentation.
    ;-)
    I would think that Flex and GWT would beat Grails, but that Grails would beat Struts and Struts 2. The Struts mailing list doesn't have that much traffic, nor does Struts 2. My belief on the reasons for this is because Struts attempts to solve only the Controller layer. ie if you want help about ORM you don't ask it on the Struts list. Because Grails attempts to solve everything from the build system down to the ORM layer we get a lot more traffic and varying questions, from people asking about Hibernate, to Spring, to Sitemesh, to GSP, to the controller layer Plus of course all of the plugins.
  14. Re: Questions[ Go to top ]

    To answer your questions:

    popularity - Grails has a rapidly growing community with over 1.6 million lines of user contributed code in the plugin repository (http://grails.org/Plugins) and the highest traffic mailing list amongst these frameworks: http://www.nabble.com/Web-Development-Framework-f16257.html
    You beat Wicket's list activity? Wow, that's impressive (but I also feel bad about your private life ;-) ).
  15. We had an urgent need of a license generation application for our product. None of our developers had any experience of grails (or any other dynamic language for that matter). I had played with rails in past and loved it but it wasn't a choice this time as our current stack is all java based. I decided to try GoG. I searched for some grails docs and send it over to my java developer and here is the feature list of what one guy accomplished in two days. 1. Role based login 2. User maintenance 3. License generation, list, detail view, modify, search, FTP, email, file download 4. Logout 5. UI for all the above functionality 6. Deploying it to our UAT environment 7. Secure access (HTTPS) 8. All of this unit tested I am not able to share the app (or even screens) as its all proprietary stuff. My experience with all of this is that no matter which stage you are in your project, you owe yourself a try to Grails.
  16. We had an urgent need of a license generation application for our product
    "product" Link is broken.
    I had played with rails in past and loved it but it wasn't a choice this time as our current stack is all java based. I decided to try GoG. I searched for some grails docs and send it over to my java developer and here is the feature list of what one guy accomplished in two days.
    Looks like this was a side project for you. I am confused why you couldnt use rails (which is more matured technology and certainly has larger penetration and hence better community support). Any pain points that you came across in implementing grails. -Brian
  17. Re: Sharing our experience on zephyr[ Go to top ]

    I am confused why you couldnt use rails (which is more matured technology and certainly has larger penetration and hence better community support).
    The Rails/Grails comparison is not as straightforward as that. The beauty of Grails is that, rather than reinvent everything, it builds the Rails idea on a whole raft of already mature technologies. For example, you can bet you'll actually get a hell of a lot more support if you run into a Hibernate problem, than if you run into an ActiveRecord problem. Likewise, I'll take Jetty over Mongrel any day (although, thanks to JRuby I could do that with Rails too ;)). And, as the guy said he was in a pure Java house, he can get all the benefit of the vast array of pre-existing, stable, mature java solutions that your in-house developers are already familiar with. So, while Grails as a project is newer than Rails, because of the sensible approach Grails has taken it is arguable which is the more mature.
  18. Recently I started to write down my experience of learning Grails. It contains a lot of touch points on various features such as GORM, Validation, Filters, TagLibs, GSP, Configuration, Themes, and more. I'll post it shortly. Best Regards, Richard L. Burton III
  19. No more writing for Iterator i = list.iterator() to loop through a list of items; list.each does the same thing more concisely and more expressively.
    Thats a pretty impressive feature. Well, it would be if this would be year 2003 :) Maybe you could take goal of updating the marketing pitch like, um, every 5 years? :) /Henri Karapuu
  20. Hosting for Grails?[ Go to top ]

    After looking at Grails I can see real value in it. It would be especially useful when putting up small CRUD applications. For example, I might build one to handle the silent auction for a fund raiser I will be involved in later this year. This would be a quick and dirty application put up for a short time so that people could enter the items procured into a central database for tracking purposes. Currently I host with lunarpages and they do offer some limited Java support. Is it trivial to build the app and then configure Tomcat and then MySQL which is usually what is offered to run Grails applications? I'm just trying to get an idea of the complexity/pain involved since I currently have no Grails experience.
  21. Re: Hosting for Grails?[ Go to top ]

    There is a command-line command named "war" to generate a war bundle for standard JEE deployment. http://grails.org/doc/1.0.x/
  22. Re: Hosting for Grails?[ Go to top ]

    It truly is very simple (unless your datamodel is very complex). As I wrote in my previous post, we were able to develop licensing app for zephyr in 2 days with no prior experience with it (we also leveraged some of the license generation algorithm that we already had developed). Grails gives you 1. a complete (full stack) folder structure. 2. Code generators (for generating code all the way from DAO layer to frontEnd) 3. Tonnes of plugins (community driven) 4. Build script (you will never miss maven and will not have to deal with bloating build.xml for ant) Its certainly worth a try. I have used lunarpages myself in past and if I remember correctly they use resin (unless they changed in past couple years). You can deploy war files easily. There is no good auto deployment built in Grails (I couldn't find any plugins) but manual deployment is not too cumbersome. -Shailesh
  23. The civil reaction to my article series here and elsewhere has been very encouraging. I have absolutely no interest in creating yet another "My Dad's web framework can beat up your Dad's web framework" dialog. Programming languages and frameworks all have relative strengths and weaknesses. Sadly, there are no silver bullets in our industry. As a Java developer, Groovy and Grails have absolutely hit the sweet-spot for me -- modern programming advances on a well-established, well-understood, well-supported platform (Java/JEE, Hibernate, Spring, et al). If you don't have a history with the JVM, there are plenty of innovative things going on in other languages -- Ruby on Rails, Django on Python. It's interesting, though, that JRuby offers RoR on the JVM, and Jython brings Django to the party as well. Finally, I was teaching a private Grails class this week. The best possible way to hear that you made it on to the front page of TSS is having one of your students tell you in class...(grin) I'll be speaking on Groovy and Grails at the Vegas TSS show in March. See you there...
  24. Sadly, there are no silver bullets in our industry.
    Why do we need a silver bullet when we've found the Holy Grail(s)?
  25. Grails is a great framework but dont fall into the RAD trap. Scaffolding is just for testing and demo purpose. Now if Grails could have a plugin (*that worked*) for eclipse and/or netbeans, that would be great. But for the moment, going to my IDE, to my console and back again is a pain. What I really liked about Grails is 1) no-pain controllers 2) Services with the XFire plugin 3) Tags ... can you say 'easy' ! 4) Ajax integration with XFire plugins