Grails in Action
eBook - ePub

Grails in Action

Peter Ledbrook, Glen Smith

Partager le livre
  1. 576 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Grails in Action

Peter Ledbrook, Glen Smith

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

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

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Grails in Action est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Grails in Action par Peter Ledbrook, Glen Smith en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming in Java. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Éditeur
Manning
Année
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...

Table des matiĂšres