Part I. Getting Started

In this first part of the book we summarize the web's foundations and show how to build a simple back-end web application using Java, JPA, JSF and the MySQL database. It shows how to build such an app with minimal effort. A back-end web app is a distributed web app where essentially all work is performed by the back-end component, including data validation and UI page creation, while the front-end only consists of a web browser's rendering of HTML-forms-based UI pages.

The minimal version of a Java back-end data management application discussed in this part only includes a minimum of the overall functionality required for a complete app. It takes care of only one object type ("books") and supports the four standard data management operations (Create/Read/Update/Delete), but it needs to be enhanced by styling the user interface with CSS rules, and by adding further important parts of the app's overall functionality.

Table of Contents

1. A Quick Tour of the Foundations of Web Apps
1. The World Wide Web (WWW)
2. HTML and XML
2.1. XML documents
2.2. Unicode and UTF-8
2.3. XML namespaces
2.4. Correct XML documents
2.5. The evolution of HTML
2.6. HTML forms
3. Styling Web Documents and User Interfaces with CSS
4. JavaScript - "the assembly language of the Web"
4.1. JavaScript as an object-oriented language
4.2. Further reading about JavaScript
5. Accessibility for Web Apps
6. Quiz Questions
6.1. Question 1: Well-Formed XML
6.2. Question 2: HTML Forms
2. Java Summary
1. Compared to JavaScript, what is different in Java?
2. JavaBean Classes and Entity Classes
3. Building a Minimal Java Web App in Seven Steps
1. Step 1 - Set up the Folder Structure
2. Step 2 - Write the Model Code
2.1. Storing Book objects in a database table books
2.2. Creating a new Book instance and storing it
2.3. Retrieving all Book instances
2.4. Updating a Book instance
2.5. Deleting a Book instance
2.6. Creating test data
2.7. Clearing all data
3. Step 3 - Configure the App
3.1. Create the EntityManager and UserTransaction objects
3.2. Configure the JPA database connection
3.3. Create the main template
3.4. Define the managed beans needed in facelets
3.5. Build the WAR file and deploy it to TomEE
4. Step 4 - Implement the Create Use Case
5. Step 5 - Implement the Retrieve/List All Use Case
6. Step 6 - Implement the Update Use Case
7. Step 7 - Implement the Delete Use Case
8. Run the App and Get the Code
9. Possible Variations and Extensions
9.1. Accessibility for Web Apps
9.2. Using resource URLs
9.3. Dealing with date/time information using Date and <time>
9.4. Using an alternative DBMS
10. Points of Attention
10.1. Code clarity
10.2. Boilerplate code
10.3. Offline availability
10.4. Architectural separation of concerns
4. Practice Projects
1. Project 1 - Managing Information about Movies
2. Project 2 - Managing Information about Countries