You are previewing Enterprise Application Development with Ext JS and Spring.
O'Reilly logo
Enterprise Application Development with Ext JS and Spring

Book Description

Designed for intermediate developers, this superb tutorial will lead you step by step through the process of developing enterprise web applications combining two leading-edge frameworks. Take a big leap forward in easy stages.

  • Embark on the exciting journey through the entire enterprise web application development lifecycle

  • Leverage key Spring Framework concepts to deliver comprehensive and concise Java code

  • Build a real world ExtJS web application that interacts with dynamic database driven data

  • In Detail

    Spring and ExtJS 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 ExtJS 4 development environment and introduce key ExtJS 4 concepts, including MVC and practical design conventions.

    Covering a variety of important ExtJS 4 strategies and concepts, you will be fully-equipped to implement a variety of different user interfaces using the ExtJS MVC design pattern. Your journey ends by exploring the production build and deployment process using Maven, Sencha Cmd and Glassfish.

    Table of Contents

    1. Enterprise Application Development with Ext JS and Spring
      1. Table of Contents
      2. Enterprise Application Development with Ext JS and Spring
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      8. Preface
        1. What the book covers
        2. What you need for this book
        3. Who this book is for
          1. Application architects
          2. Java developers
          3. Ext JS developers
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Preparing Your Development Environment
        1. Installing MySQL
        2. Installing the Java SE Development Kit (JDK)
        3. Installing the NetBeans IDE
        4. Introducing Maven
        5. Creating the Maven Web Application project
          1. Understanding the POM and dependency management
          2. Understanding dependency scope
          3. Defining Maven properties
          4. Understanding Maven-build plugins
          5. Executing the Maven build
        6. Starting the GlassFish 4 server
        7. Running the Task Time Tracker project
        8. Summary
      10. 2. The Task Time Tracker Database
        1. Connecting NetBeans with MySQL
        2. The 3T database
          1. The company table
          2. The projects table
          3. The tasks table
          4. The user table
          5. The task log table
        3. Enterprise options for the 3T database
          1. Password encryption
          2. LDAP integration
          3. Audit trails
            1. Logon activity audits
            2. Custom audit tables
        4. Summary
      11. 3. Reverse Engineering the Domain Layer with JPA
        1. Understanding the reasons for using JPA
        2. Understanding JPA implementations
        3. Reverse engineering with NetBeans
        4. Introducing the persistence.xml file
        5. Refactoring the Java classes
          1. The Company.java file
            1. The @Entity annotation
            2. The @Table annotation
            3. The @Id annotation
            4. The @GeneratedValue annotation
            5. The @Basic annotation
            6. The @Column annotation
            7. The @NotNull and @Size annotations
            8. The @OneToMany annotation
            9. The @NamedQueries annotation
          2. The Projects.java file
            1. The @ManyToOne annotation
          3. Bidirectional mapping and owning entities
          4. The Task.java file
          5. The User.java file
          6. The TaskLog.java file
        6. Introducing the Java Persistence Query Language
          1. Defining named queries
        7. Refactoring Java equals() and hashCode()
        8. Summary
      12. 4. Data Access Made Easy
        1. Defining the DAO interfaces
          1. Adding the CompanyDao interface
          2. Adding the ProjectDao interface
          3. Defining a generic DAO interface
          4. The TaskDao interface
          5. The UserDao interface
          6. The TaskLogDao interface
        2. Defining the generic DAO implementation
          1. The Simple Logging Facade for Java
          2. The@PersistenceContext(unitName = "tttPU") line
          3. The @Transactional annotation
            1. The Propagation.REQUIRED property
            2. The Propagation.SUPPORTS property
            3. The readOnly property
            4. Other transaction properties
        3. Defining the DAO implementations
          1. The CompanyDaoImpl class
          2. The ProjectDaoImpl class
          3. The TaskDaoImpl class
          4. The UserDaoImpl class
          5. The TaskLogDaoImpl class
        4. A better domain layer
        5. Exercise – a simple change request
        6. Summary
      13. 5. Testing the DAO Layer with Spring and JUnit
        1. Unit testing overview
          1. The benefits of unit testing
        2. Configuring the test environment
          1. The jdbc.properties file
          2. The logback.xml file
          3. The test-persistence.xml file
        3. Introducing the Spring IoC container
          1. Exploring the testingContext.xml file
            1. The Spring XML namespaces
            2. The property file configuration
            3. Creating the JDBC DataSource
            4. Defining helper beans
            5. Defining the EntityManagerFactory class
            6. Configuring the transaction manager
            7. Autowiring beans
            8. Thanks for the plumbing!
          2. Enabling the Maven environment for testing
        4. Defining a test case superclass
        5. Defining the CompanyDao test case
        6. Running the JUnit test cases with Maven
          1. Running the CompanyDaoTest.java file
          2. The results for the CompanyDaoTests.testMerge test case
          3. The results for the CompanyDaoTests.testFindAll test case
          4. The results for the CompanyDaoTests.testFind test case
          5. Results for the CompanyDaoTests.testPersist test case
          6. Results for the CompanyDaoTests.testRemove test case
        7. JPA traps for the unwary
        8. Exercises
        9. Summary
      14. 6. Back to Business – The Service Layer
        1. Service layer considerations
        2. Building the service layer
          1. The Result Data Transfer Object
          2. The AbstractService.java class
        3. The service layer interfaces
        4. Implementing the service layer
          1. Authentication, authorization, and security
          2. The CompanyService implementation
          3. The TaskService implementation
          4. The TaskLogService implementation
        5. Testing the service layer
        6. Automating the service layer tests
        7. Exercises
        8. Summary
      15. 7. The Web Request Handling Layer
        1. A brief history of Web MVC
        2. Request handling for enterprise web applications
        3. Building the request handling layer
          1. Preparing for JSON generation
            1. Implementing the Company addJson method
            2. Implementing the Project addJson method
            3. Implementing the Task addJson method
            4. Implementing the User addJson method
            5. Implementing the TaskLog addJson method
          2. A note on JSON
        4. Creating the request handlers
          1. Defining the AbstractHandler superclass
          2. Defining the SecurityHandler class
            1. The @Controller and @RequestMapping annotations
            2. The @ResponseBody annotation
            3. The @RequestParam annotation
            4. Authenticating a user
            5. Logging out
          3. Defining the CompanyHandler class
          4. Defining the ProjectHandler class
        5. The Spring HandlerInterceptor interface
        6. The Spring MVC configuration
        7. Defining the TaskLogHandler class
          1. The @InitBinder annotation
        8. More on Spring MVC
        9. Exercises
        10. Summary
      16. 8. Running 3T on GlassFish
        1. Configuring the 3T web application
          1. The Spring applicationContext.xml file
          2. The web.xml file
          3. The glassfish-web.xml file
        2. Configuring the Maven pom.xml file
        3. Adding eclipselink.target-server to the persistence.xml file
        4. Adding the logback.xml file to your resources directory
        5. Configuring the GlassFish server
          1. Renaming the setup directory
          2. Starting the GlassFish server in NetBeans
          3. Configuring the JDBC connection pool
          4. Configuring the JDBC resource
        6. Running 3T
        7. Managing GlassFish without NetBeans
        8. Summary
      17. 9. Getting Started with Ext JS 4
        1. The importance of application design
        2. Ext JS 4 MVC concepts
          1. Model
          2. View
          3. Controller
          4. Ext JS 4 flexibility
        3. Ext JS 4 design conventions and concepts
        4. Practical conventions
          1. Project structure
          2. Naming conventions
            1. Naming stores and models
            2. Naming views
            3. Naming controllers
            4. Naming xtypes
        5. The Ext JS 4 development environment
          1. Installing Sencha Cmd
          2. Installing Ext JS 4 SDK
        6. Generating the 3T Ext JS 4 application skeleton
          1. The index.html file
          2. The app.js and Application.js files
          3. The bootstrap.js and bootstrap.css files
          4. The app/Viewport.js and app/view/Main.js files
          5. The app/controller/Main.js file
        7. Creating components using Sencha Cmd
          1. Generating model skeletons
          2. Generating views and controllers using Sencha Cmd
        8. Summary
      18. 10. Logging On and Maintaining Users
        1. Layouts, screens, and workflows
          1. Defining view components
        2. Building our views
          1. Defining the Logon window
            1. Using the initComponent() function
          2. Defining the viewport
            1. The MainHeader.js view
            2. The MainCards.js file
          3. Defining the Welcome panel
          4. Defining the user management components
            1. The ManageUsers.js file
            2. The UserForm.js file
            3. The UserList.js file
            4. The User store
        3. Models and persistence
          1. Defining the proxy
          2. Comparing AJAX and REST proxies
          3. Defining the reader
          4. Defining the writer
          5. Defining validations
        4. Controlling the Logon and Viewport actions
          1. The MainController.js file
        5. Controlling our user views
          1. The doAddUser function
          2. The doSelectUser function
          3. The doSaveUser function
          4. The doDeleteUser function
        6. Let's log on!
        7. Let's maintain users
        8. Summary
      19. 11. Building the Task Log User Interface
        1. Task log workflows and layouts
        2. Building our task log views
          1. The ManageTaskLogs.js file
          2. The TaskLogForm.js file
          3. The TaskLogList.js file
        3. Defining our models
          1. The TaskLog Model
          2. The Project model
          3. The Task Model
        4. Defining our stores
          1. The TaskLog store
          2. The Project store
          3. The Task store
        5. Controlling the TaskLog actions
        6. Testing the task log interface
        7. Summary
      20. 12. 3T Administration Made Easy
        1. Administration workflows and layouts
        2. Building the 3T administration interface
          1. The ManageTasks.js file
          2. The CompanyForm.js file
          3. The ProjectForm.js file
          4. The TaskForm.js file
          5. The CompanyTree.js file
          6. Introducing the Ext.data.TreeStore class
        3. Generating a JSON tree in the CompanyHandler class
          1. The CompanyHandler.getTreeNodeId() method
          2. The CompanyHandler.getCompanyTreeJson() method
        4. Controlling the 3T administration
          1. Defining the Company model and store
          2. The doAfterActivate function
          3. The doSelectTreeItem function
          4. The doSave functions
          5. The doDelete functions
          6. The doAdd functions
        5. Testing the 3T administration interface
        6. Dynamically loading tree nodes
        7. Displaying multiple tree columns
        8. Drag-and-drop made easy
        9. Summary
      21. 13. Moving Your Application to Production
        1. Compiling with Sencha Cmd
        2. Ext JS 4 theming
        3. Compiling for production use
        4. Integrating Sencha Cmd compiling with Maven
        5. Adding the build version and timestamp
        6. Building a slimmer WAR file
        7. Deploying the WAR file to GlassFish
          1. Opening the GlassFish admin console
          2. GlassFish security basics
          3. Deploying the WAR file using the admin console
          4. Deploying the WAR file using asadmin
          5. Further deployment information and reading
        8. GlassFish performance tuning and optimization
        9. Summary
      22. A. Introducing Spring Data JPA
      23. Index