Book Image

Enterprise Application Development with Ext JS and Spring

By : Gerald Gierer
Book Image

Enterprise Application Development with Ext JS and Spring

By: Gerald Gierer

Overview of this book

Spring and Ext JS are cutting edge frameworks that allow us to build high performance web applications for modern devices, that are now consuming data at a faster rate than ever before. It is the appropriate time for you to understand how to best leverage these technologies when architecting, designing, and developing large scale web development projects. This practical guide condenses an approach to web development that was gained from real world projects, and outlines a simple, practical approach to developing high performance, and enterprise grade web applications. Starting with configuring Java, NetBeans, and MySQL to prepare your development environment, you will then learn how to connect your NetBeans IDE to the MySQL database server. We will then explore the Task Time Tracker (3T) project database structure and populate these tables with test data. Following on from this, we will examine core JPA concepts after reverse engineering the domain layer with NetBeans. Leveraging the Data Access Object design pattern, you will learn how to build the Java DAO implementation layer assisted by generics in base classes, followed by a Data Transfer Object enabled service layer to encapsulate the business logic of your 3T application. The final chapters that focus on Java explore how to implement the request handling layer using Spring annotated controllers, and deploy the 3T application to the GlassFish server. We will then configure the Ext JS 4 development environment and introduce key Ext JS 4 concepts, including MVC and practical design conventions. Covering a variety of important Ext JS 4 strategies and concepts, you will be fully-equipped to implement a variety of different user interfaces using the Ext JS MVC design pattern. Your journey ends by exploring the production build and deployment process using Maven, Sencha Cmd and GlassFish.
Table of Contents (22 chapters)
Enterprise Application Development with Ext JS and Spring
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Introducing Spring Data JPA
Index

Preface

Enterprise application development is an art form rarely acknowledged in this fast-paced technical world. This book describes the patterns and strategies that will simplify large-scale development projects using two of the most popular technologies available: the Spring Framework and Sencha Ext JS. Each chapter defines and builds a concise layer in the enterprise application stack, condensing an approach to web development that was gained from many years of developing real-world projects. We cover quite an extensive conceptual ground, so be prepared for an interesting journey!

This book is not an introduction to Java, JavaScript, or any web development concepts. There are significant amounts of practical code in both Java and JavaScript languages, so an understanding of these technologies is required. If you are not familiar with Java and associated concepts such as object-oriented programming, you may be challenged when following the examples and explanations. The same can be said for Ext JS development; you need to have some experience with the fundamental concepts, including the framework APIs, to follow most examples.

You do not need to be an expert, but beginners may wish to start their journey elsewhere.

Regardless of your experience and background, the practical examples provided in this book are written in a way to thoroughly cover each concept before moving on to the next chapter.

What the book covers

Chapter 1, Preparing Your Development Environment, discusses the installation and configuration for the development environment, including the Java Development Kit, NetBeans, and MySQL. We will also introduce Maven, create a new NetBeans project, and deploy the project to the GlassFish 4 application server.

Chapter 2, The Task Time Tracker Database, defines the Task Time Tracker (3T) database design and helps configure NetBeans as a client of the MySQL server. We create and populate all the tables and identify the possible enhancements that could be appropriate for enterprise use.

Chapter 3, Reverse Engineering the Domain Layer with JPA, helps us reverse engineer the 3T database using the NetBeans IDE to create a domain layer of JPA entities. These entities are explored and refactored as we examine and define core JPA concepts.

Chapter 4, Data Access Made Easy, introduces the Data Access Object (DAO) design pattern and helps implement a robust data access layer using the domain classes we defined in the previous chapter. Java generics and interfaces, the Simple Logging Facade for Java (SLF4J), the JPA EntityManager, and transactional semantics are also introduced.

Chapter 5, Testing the DAO Layer with Spring and JUnit, introduces the configuration of a JUnit testing environment and the development of test cases for several of our DAO implementations. We introduce the Spring Inversion of Control (IoC) container and explore the Spring configuration to integrate Spring-managed JUnit testing with Maven.

Chapter 6, Back to Business – The Service Layer, examines the role of the service layer in enterprise application development. Our 3T business logic is then implemented by the Data Transfer Objects (DTO) design pattern using Value Objects (VO). We also examine writing test cases prior to coding the implementation—a core principle of test-driven development and extreme programming.

Chapter 7, The Web Request Handling Layer, defines a request handling layer for web clients that generates JSON data using the Java API for JSON processing, which is a new API introduced in Java EE 7. We implement the lightweight Spring controllers, introduce Spring handler interceptors, and configure Spring MVC using Java classes.

Chapter 8, Running 3T on GlassFish, completes our Spring configuration and allows us to deploy the 3T application to the GlassFish 4 server. We also configure the GlassFish 4 server to run independently of the NetBeans IDE, as would be the case in enterprise environments.

Chapter 9, Getting Started with Ext JS 4, introduces the powerful Ext JS 4 framework and discusses the core Ext JS 4 MVC concepts and practical design conventions. We install and configure our Ext JS development environment using Sencha Cmd and the Ext JS 4 SDK to generate our 3T application skeleton.

Chapter 10, Logging On and Maintaining Users, helps us develop the Ext JS 4 components that are required for logging on to the 3T application and maintaining users. We will discuss the Ext JS 4 model persistence, build a variety of views, examine application concepts, and develop two Ext JS controllers.

Chapter 11, Building the Task Log User Interface, continues to enhance our understanding of the Ext JS 4 components as we implement the task log user interface.

Chapter 12, 3T Administration Made Easy, enables us to develop the 3T Administration interface and introduces the Ext JS 4 tree component. We examine dynamic tree loading and implement drag-and-drop tree actions.

Chapter 13, Moving Your Application to Production, will help us prepare, build, and deploy our 3T project to the GlassFish server. We introduce Ext JS theming, integrate Sencha Cmd compiling with Maven to automate the Ext JS 4 app-all.js file generation process, and learn how to deploy our production build on the GlassFish server.

Appendix, Introducing Spring Data JPA, provides a very brief introduction to Spring Data JPA as an alternative to the implementation discussed in Chapter 4, Data Access Made Easy.

What you need for this book

The examples in this book can be run on any Windows, Mac, or Linux platform that supports the following software:

  • Java Development Kit (JDK) 1.7

  • NetBeans 7.4+

  • MySQL 5+

  • Sencha Cmd

All of the software are available for free download at the websites listed in the appropriate chapters.

Who this book is for

This book is particularly relevant to those working in large-scale web application development projects, including application architects, Java developers, and Ext JS developers.

Application architects

Architects understand the big picture from a technical perspective and are responsible for laying out a blueprint for development standards. This book will introduce you to the power of the Spring Framework and Sencha Ext JS and how you can best leverage these technologies when designing your next project.

Java developers

Regardless of your level of understanding, you will learn how the Spring Framework encourages good programming practices. This includes a clean, layered structure that is easy to enhance and maintain. Those new to Spring will be surprised at how little effort is required to achieve significant results. For both new and experienced Spring developers, the focus will be best practices for enterprise web development to allow seamless integration with Sencha Ext JS clients. If you have never worked with Sencha Ext JS, you will be surprised at how quickly powerful UIs can bring backend data to life.

Ext JS developers

Sencha Ext JS is a powerful framework that is used to build enterprise applications that are cross-browser compliant. This book will solve real-world problems right from analysis to providing fully functional solutions. You will see the many stages of development that are usually hidden from Ext JS developers; you will also get introduced to the steps required to produce JSON data for client consumption. The chapters focusing on the Ext JS components will introduce simple strategies for maintainable development based on the latest MVC design patterns.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, folder names, filenames, file extensions, pathnames, dummy URLs, and user input are shown as follows: "The ManageTaskLogs definition is as follows:"

A block of code is set as follows:

Ext.define('TTT.store.Task', {
    extend: 'Ext.data.Store',
    requires: ['TTT.model.Task'],
    model: 'TTT.model.Task',
    proxy: {
        type: 'ajax',
        url:'task/findAll.json',
        reader: {
            type: 'json',
            root: 'data'
        }
    }    
});

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

controllers: [
  'MainController',
  'UserController',
  'TaskLogController'
],
models: [
  'User',
  'Project',
  'Task',
  'TaskLog'
],
stores: [
  'User',
  'Project',
  'Task',
  'TaskLog'
]

Any command-line input or output is written as follows:

sencha –sdk ext compile -classpath=app page -yui -in index.html -out build/index.html

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Adding a new task log will preserve the currently selected Date and Project, if present:".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.