Grails in Action
eBook - ePub

Grails in Action

Peter Ledbrook, Glen Smith

Compartir libro
  1. 576 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Grails in Action

Peter Ledbrook, Glen Smith

Detalles del libro
Vista previa del libro
Índice
Citas

Información del 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

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Grails in Action un PDF/ePUB en línea?
Sí, puedes acceder a Grails in Action de Peter Ledbrook, Glen Smith en formato PDF o ePUB, así como a otros libros populares de Computer Science y Programming in Java. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Editorial
Manning
Año
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...

Índice