Grails in Action
eBook - ePub

Grails in Action

Peter Ledbrook, Glen Smith

Condividi libro
  1. 576 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Grails in Action

Peter Ledbrook, Glen Smith

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

Summary Grails in Action, Second Edition is a comprehensive introduction to Grails 2 focused on making you super-productive fast. In this totally revised new edition, you'll master Grails 2.3 core skills as you apply TDD techniques to developing a full-scale Twitter clone. Along the way you'll learn the latest single-page web app UI techniques, work with NoSQL backends, integrate with enterprise messaging, and implement a complete RESTful API for your services. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the Technology It may be time for you to stop reconfiguring, rewriting, and recompiling your Java web apps. Grails, a Groovy-powered web framework, hides all that busy work so you can concentrate on what your applications do, not how they're built. In addition to its famously intuitive dev environment and seamless integration with Spring and Hibernate, the new Grails 2.3 adds improved REST support, better protection against attacks from the web, and better dependency resolution. About the Book Grails in Action, Second Edition is a comprehensive introduction to Grails 2. In this totally revised edition you'll master Grails as you apply TDD techniques to a full-scale example (a Twitter clone). Along the way you'll learn single-page web app techniques, work with NoSQL back ends, integrate with enterprise messaging, implement a RESTful API... and more.No Java or Groovy knowledge is required. Some web development and OOP experience is helpful. What's Inside

  • Covers Grails 2.3 from the ground up
  • Agile delivery and testing using Spock
  • How to use and manage plugins
  • Tips and tricks from the trenches


About the Authors There's no substitute for experience: Glen Smith and Peter Ledbrook have been fixtures in the Grails community, contributing code, blogging, and speaking at conferences worldwide, since Grails 0.2. Table of Contents
PART 1 INTRODUCING GRAILS

  • Grails in a hurry
  • The Groovy essentials
  • PART 2 CORE GRAILS
  • Modeling the domain 63
  • Creating the initial UI
  • Retrieving the data you need
  • Controlling application flow
  • Services and data binding
  • Developing tasty forms, views, and layouts
  • PART 3 EVERYDAY GRAILS
  • Building reliable applications
  • Using plugins: just add water
  • Protecting your application
  • Exposing your app to other programs
  • Single-page web applications (and other UI stuff)
  • Understanding Spring and transactions
  • PART 4 ADVANCED GRAILS
  • Understanding events, messaging, and scheduling
  • NoSQL and Grails
  • Beyond compile, test, run
  • Grails in the cloud
  • BONUS ONLINE CHAPTERS
  • Advanced GORM kung fu
  • Developing plugins

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Grails in Action è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Grails in Action di Peter Ledbrook, Glen Smith in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Computer Science e Programming in Java. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Editore
Manning
Anno
2014
ISBN
9781638355311

Part 1. Introducing Grails

The field of Java-based web application frameworks has made great strides in usability, but creating an application with them is still hard work. Grails’s core strength is developing web applications quickly, so you’ll jump into writing your first application right away.
In chapter 1, we expose you to the core parts of Grails by developing a simple Quote of the Day (QOTD) application from scratch. You’ll store to and query from the database, develop business logic, write tests, and add Ajax functionality. By the end of it, you’ll have a feel for the parts of Grails.
To develop serious Grails applications, you need a firm grasp of Groovy—the underlying dynamic language that makes Grails tick. In chapter 2, we take you on a whirlwind tour of core Groovy concepts and introduce the syntax.
By the end of part 1, you’ll understand the power of Groovy and Grails and be ready to take on the world. Feel free to do so—Grails encourages experimentation. But you might want to stick around for part 2, where we take you deeper into the core parts of Grails.

Chapter 1. Grails in a hurry . . .

This chapter covers
  • What is Grails?
  • Core Grails philosophy
  • Grails installation
  • Key components of a Grails application
  • Your first Grails application—developing and deploying it
“Help, I’ve lost my Mojo!” That statement is a concise summary of what developers feel when working with any of the plethora of Java web frameworks. Each change requires time spent editing configuration files, customizing web.xml files, writing injection definitions, tweaking build scripts, modifying page layouts, and restarting apps. Aaaahhhh! “Where has all the fun gone? Why is everything so tedious? I wanted to whip up a quick app to track our customer signups! There must be a better way . . .” We hear you.
Grails is a next-generation Java web development framework that draws on best-of-breed web development tooling, techniques, and technologies from existing Java frameworks, and combines them with the power and innovation of dynamic language development. The result is a framework that offers the stability of technologies you know and love, but shields you from the noisy configuration, design complexity, and boilerplate code that make existing Java web development tedious. Grails allows you to spend your time implementing features, not editing XML.
But Grails isn’t the first player to make such claims. You’re thinking, “Please don’t let this be YAJWF (Yet Another Java Web Framework)!” Because if the Java development world is famous for one thing, it’s having an unbelievably large number of web frameworks. Struts, WebWork, JavaServer Faces (JSF), Spring MVC, Seam, Wicket, Tapestry, Stripes, Google Web Toolkit (GWT), and the list goes on and on—all with their own config files, idioms, templating languages, and gotchas. And now we’re introducing a new one?
The good news is that this ain’t your grandma’s web framework. We’re about to take you on a journey to a whole new level of getting stuff done—and getting it done painlessly. We’re excited about Grails because we think it’s time that Java web app development was fun again! It’s time for you to sit down for an afternoon and crank out something you’d be happy demoing to your boss, client, or the rest of the internet. Grails is that good.
In this chapter, we take you through developing your first Grails app. Not a toy, either. Something you can deploy and show your friends. An app that’s data-driven and Ajax-powered that has full CRUD (create, read, update, delete) implementation, a template-driven layout, and even unit tests. All in the time it takes to eat your lunch, with less than 100 lines of code. Seriously.
But before you fire up your IDE and get your hands dirty writing code, you may need more convincing about why Grails is such a game-changer and should be on your radar.

1.1. Introducing Grails

Grails is a next-generation Java web development framework that generates developer productivity gains through the confluence of a dynamic language, a convention over configuration philosophy, powerfully pragmatic supporting tools, and an agile perspective drawn from the best emerging web development paradigms.

1.1.1. Why Grails changed the game

Grails entered the Java Web Application landscape in 2006 and has grown steadily in adoption since. Taking full advantage of Groovy as the underlying dynamic language, Grails made it possible to create a Book object and query it with dynamic methods such as Book.findByTitle("Grails in Action") or Book.findAllBy-DatePublished-GreaterThanAndTitleLike(myDate, "Grails"), even though none of those methods existed on the Book object.
Even better, you could access any Java code or libraries you were already using, and the language syntax was similar enough to Java to make the learning curve painless. But best of all, at the end of the day you had a WAR file to deploy to your existing Java app server—no special infrastructure required, and no management awareness needed.
The icing on the cake was that Grails was built on Spring, Hibernate, and other libraries already popular and used by enterprise Java developers. It was like turbocharging existing development practices without sacrificing reliability or proven technologies.
Grails’s popularity exploded. Finally, Java web developers had a way to take all the cool ideas that Rails had brought to the table and apply them to robust enterprise-strength web application development, without leaving behind any of their existing skills, libraries, or infrastructure.

1.1.2. Seven big ideas

That’s enough history about how Grails came to be such a popular Java web framework. But if you (or your manager) need further convincing that Grails is an outstanding option for your next big web app project, the following subsections discuss seven of the big ideas (shown in figure 1.1) that drove Grails to such a dominant position in the emerging next-gen Java web frameworks market.
Figure 1.1. The Grails ecosystem is a powerful confluence of people, ideas, and technology.
Big idea #1: convention over configuration
One of the things you’ll notice about developing with Grails is how few configuration files exist. Grails makes most of its decisions based on sensible defaults drawn from your source code:
  • Add a controller class called ShopController with an action called order, and Grails will expose it as a URL of /yourapp/shop/order.
  • Place your view files in a directory called /views/shop/order, and Grails will link everything for you without a single line of configuration.
  • Create a new domain class called Customer, and Grails will automatically create a table called customer in your database.
  • Add fields to your Customer object, and Grails will automatically create the necessary fields in your customer table on the fly (including the right data types based...

Indice dei contenuti