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

Generating a JSON tree in the CompanyHandler class


It is now time to enhance the CompanyHandler class to generate the required JSON to load the tree store and display the company tree. We will create two new methods to implement this functionality.

The CompanyHandler.getTreeNodeId() method

The CompanyHandler.getTreeNodeId() helper method generates a unique ID based on the ID of the EntityItem class. It will be used to generate type-specific IDs for each node.

private String getTreeNodeId(EntityItem obj){
  String id = null;

  if(obj instanceof Company){
    id = "C_" + obj.getId();
  } else if(obj instanceof Project){
    id = "P_" + obj.getId();
  } else if(obj instanceof Task){
    id = "T_" + obj.getId();
  }
  return id;
}

The CompanyHandler.getCompanyTreeJson() method

The CompanyHandler getCompanyTreeJson() method is mapped to the company/tree.json URL and has the following definition:

@RequestMapping(value="/tree", method=RequestMethod.GET, produces={"application/json"})
@ResponseBody
public...