Book Image

Digital Java EE 7 Web Application Development

By : Peter Pilgrim
Book Image

Digital Java EE 7 Web Application Development

By: Peter Pilgrim

Overview of this book

Digital Java EE 7 presents you with an opportunity to master writing great enterprise web software using the Java EE 7 platform with the modern approach to digital service standards. You will first learn about the lifecycle and phases of JavaServer Faces, become completely proficient with different validation models and schemes, and then find out exactly how to apply AJAX validations and requests. Next, you will touch base with JSF in order to understand how relevant CDI scopes work. Later, you’ll discover how to add finesse and pizzazz to your digital work in order to improve the design of your e-commerce application. Finally, you will deep dive into AngularJS development in order to keep pace with other popular choices, such as Backbone and Ember JS. By the end of this thorough guide, you’ll have polished your skills on the Digital Java EE 7 platform and be able to creat exiting web application.
Table of Contents (21 chapters)
Digital Java EE 7 Web Application Development
Credits
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

This is a book about the Java EE 7 platform and web digital development, and it is a continuation of the first book Java EE 7 Developer Handbook. The entire focus of this tome is the space and software architecture between the frontend technologies and business logic tier. While there was a lack of printing space and working balance between life and time for this subject in my first book, in this book Digital Java EE 7, there is plenty of effort and determination to write exclusively about the Java presentation tier. This book was written for the developers who want to become superior and adept at building a web application on JVM with the standard Java EE 7 platform.

This book mostly covers the presentation tier from the Java standard's point of view. Therefore, there are entire chapters dedicated to JavaServer Faces as it is the most important and oldest dedicated web framework on the Java EE 7 platform. Even though the technology has been around since 2004, there are commercial organizations and businesses around the world that rely on JSF. They range from blue-chip companies to well-respected investment banks. Yet, with the Java EE 7 release, JSF 2.2 has several key features that web developers will enjoy and find incredibly helpful such as the HTML5 friendly markup support and Faces Flow.

As a reader, it is my hope that you will become enlightened on the path to build software that enables you to stride up the mountainous paths of the contemporary Java web technology and that you will gain the qualification of an accomplished master (or mistress) in your mind.

So, starting with JSF, we will learn about the framework with a thorough introduction to its concepts. We will progress to the building of the JSF input forms and learn how to validate their input in several ways. The most important task of developing Create Retrieve Update and Delete (CRUD) for JSF web applications will hit the nail squarely on the head. Afterwards, we will add more style and finesse to the JSF applications. On the way, we will write applications that validate with AJAX for an immediate effect. We will continue our adventure into the elegant world of conversational scope backing bean controllers. We will find that these are handy little things that we will map together and capture our stakeholders' customer journeys. Finally, we will learn about Faces Flows, which are a standout addition in JSF 2.2.

No Java web technology book would be complete without telling the reader about the JavaScript programming language and emerging technologies. Many senior Java engineers would agree that Java on the Web has—to some degree—conceded ground on the presentation tier to the JavaScript client-side frameworks. Building REST/UI frontend applications are now so common that it is difficult for the so-called digital Java engineer to ignore the influence of jQuery, RequireJS, and others. There are several known JavaScript frameworks out there in the wild. In this book, we will cover AngularJS. We will step into the middle of that blustery windy bridge in between the two major landscapes of Java, JVM, and JavaScript. I can't promise you that it will not be scary, but you might find yourself pleasantly surprised by the way that you will stand comfortably and negotiate the ledges and handholds between both the JAX-RS services and AngularJS controllers.

At the far end of this book, we have a special just-in-time release for you. We dedicate an entire single chapter to the upcoming Java EE 8 Model-View-Controller, which may become an alternative sizzling emerald in the way we build future REST/UI applications. Beyond this book's finish line, we have put together three essential appendices that I hope will act as excellent reference material.

At the end of each chapter, we have dedicated a special section to educational exercises, which I hope you find relevant and decent, and you have fun learning while your thought processes are being conveniently stretched. This was written for you, the Java web developer on a mission to innovate. Enjoy!

You can find my blog at http://www.xenonique.co.uk/blog/. You can follow me on Twitter at @peter_pilgrim.

The source code for this book is available on GitHub at https://github.com/peterpilgrim/digital-javaee7.

What this book covers

Chapter 1, Digital Java EE 7, introduces the topic of the enterprise Java platform with a perspective to web technology. We will see a brief JSF example, study the JavaScript module pattern, and examine the Java EE modern web architecture.

Chapter 2, JavaServer Faces Lifecycle, starts with the essential elements of the JSF framework. We will learn about the JSF phases and the lifecycle, custom tags, common attributes, and expression language.

Chapter 3, Building JSF Forms, gets us started with how to build the JSF Create-Update-Retrieve-Delete application forms. We will build the forms in a modern web method with JSF custom tags around the Bootstrap HTML5 framework.

Chapter 4, JSF Validation and AJAX, dives deep into the validation of the customer's data from the input form. We will study the various ways of checking the data from the backend and the persistence layer to the frontend with client-side AJAX.

Chapter 5, Conversations and Journeys, expands our JSF knowledge into the conversational scoped beans. We will learn how to map a digital customer's journey to a controller and apply other CDI scopes to our work.

Chapter 6, Faces Flows with Finesse, covers the JSF 2.2 release key highlight of the flow scope bean. We will grasp the differences between the Faces Flows and conversational scope beans, and along the way, add user-friendly features to our application.

Chapter 7, Progressive JavaScript Frameworks and Modules, provides you with a quick overview of modern JavaScript programming from a Java engineer's point of view. We will get up to speed with jQuery and other relevant frameworks such as RequireJS and UnderscoreJS.

Chapter 8, AngularJS and Java RESTful Services, builds on our new JavaScript knowledge. We will approach the writing of single page architecture applications with the popular AngularJS framework. We will also gain experience of writing the JAX-RS service endpoints.

Chapter 9, Java EE MVC Framework, takes a look under the hood of the upcoming Java EE 8 Model-View-Controller framework. We will utilize the port of the Handlebars templating framework in Java.

Appendix A, JSF with HTML5, Resources, and Faces Flows, provides references for using HTML5 support in JSF, Resource Library Contracts, and programmatic Faces Flows. It also includes important information on internationalization with the message and resource bundles.

Appendix B, From Request to Response, provides intense reference material on the architecture of the modern Java enterprise application. It answers the question about what happens when a web request is received and eventually when a response is sent back to the client.

Appendix C, Agile Performance – Working inside Digital Teams, covers the gamut of personalities and the variety of roles in modern digital and agile software development teams.

Appendix D, Curated References, is a set of specially selected bibliographic references, resources and links for further study.

What you need for this book

For this book, you will need the following list of software on a laptop or desktop PC:

Who this book is for

You should be a Java developer with a good command over the programming language. You should already know about classes, inheritance, and Java Collections. Therefore, this book is pitched at intermediate Java developers. You may have 1-2 years of experience in Java SE core development. You should have an understanding of the core Java EE platform, although an in-depth knowledge is not strictly required. You should be comfortable with Java persistence, Java servlets, and deployment of the WAR files to an application server such as GlassFish or WildFly or an equivalent server.

This book is aimed at people who want to learn JavaServer Faces or update their existing knowledge. You may or may not have experience in JavaScript programming; however, there is a dedicated start up topic in this book. This is mostly a Java EE web development book but covering AngularJS requires you to learn or reapply JavaScript coding skills.

Whether you come from a digital environment such as an agency or software house or have just stared a professional job with web development in mind, you will find this book a great help if you have to work with other staff members in your team. You will see industry terms, but I have kept the mentioning of them to a minimum so that you can focus on the technology at hand and achieve your learning goals. However, experts may recognize certain industry ideas creeping into the questions at the end of every of chapter.

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, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

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

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

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

# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample
     /etc/asterisk/cdr_mysql.conf

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: "clicking the Next button moves you to the next screen".

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.