SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This PDF will be accessible from your Account page after purchase and requires PDF reading software, such as Acrobat® Reader®.
The eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
Build Tomorrow’s Best Mobile/Web Applications with IBM WebSphere Application Server 8.5 and IBM Worklight
This guide presents a coherent strategy for building modern mobile/web applications that are fast, responsive, interactive, reusable, maintainable, extensible, and a pleasure to use. Four IBM experts offer practical, hands-on coverage of front-end development with IBM WebSphere Application Server 8.5, IBM Worklight, and today’s most popular open source frameworks.
Using well-crafted examples, the authors introduce best practices for MobileFirst development, helping you create apps that work superbly on mobile devices and add features on conventional browsers. Throughout, you’ll learn better ways to deliver Web 2.0 apps with HTML /JavaScript front ends, RESTful Web Services, and persistent data. Proven by IBM and its customers, the approach covered in this book leads to more successful mobile/web applications—and more effective development teams.
Coverage Includes
• Developing for MobileFirst: moving from “graceful degradation” to “progressive enhancement”
• Quickly delivering lightweight JEE apps with WebSphere Application Server’s new Liberty Profile
• Implementing an agile, user-centered, page-oriented approach to design
• Constructing REST services with WebSphere Liberty, Eclipse, and JEE annotations
• Building better front-end application architectures with frameworks and JavaScript
• Designing and building complex, transactional RESTful services that interface with databases and other data sources
• Building IBM Worklight hybrid apps with open source frameworks: jQuery Mobile, Backbone, Require.js, and Handlebars
• Debugging cross-platform, multi-language modern web apps
• Promoting scalability, security, and connectivity into the wider enterprise
The IBM Press developerWorks Series pairs books with complementary resources on the developerWorks website at https://www.ibm.com/developerworks/dwbooks/
Preface xviii
Chapter 1 The Modern Web 1
How the Web Has Changed 1
The Mobile Effect 7
Mobile Application Development Styles 7
Building for the Mobile Experience 11
Choosing a Mobile Development Approach 13
The Convergence of Desktop Web and Mobile:
Multichannel Development 15
REST and Web APIs 17
IBM WebSphere and IBM Worklight 18
The Process of Building Modern Web Applications 19
Introducing the Team 19
Following a User-Centered Design and Development Process 20
Introducing User-Centered Design 22
Applying the Design Process: Descriptions from Our Example 22
Introducing Development into the Process 5
Division of Labor: Defining the User Model and REST Interfaces 25
Summary 27
Endnotes 27
Chapter 2 WAS and the Liberty Profile 29
How We Got Here 29
A Brief History of WAS 29
What Changed in the Programming Model? 31
What Is Liberty? 33
Some Coding Considerations and a Servlet and JDBC Example 36
Deploying the Example Using the Liberty Profile 41
Server Creation and Structure 42
Deploying an Application on a Server 43
Testing the Sample Application 44
Running the Example Within Eclipse 45
Summary 48
Endnotes 48
Chapter 3 Design 49
Agile UI Design Process 49
More on User Centric Design 51
Design for Multichannel 52
Page-Oriented User Interfaces 53
Patterns for User Interface Design Web 55
View Interaction Patterns 55
Targeted Mobile Apps vs. Multichannel Applications 57
UI Design Example 58
Summary 63
Chapter 4 REST Web Services in WebSphere Liberty 65
What Is REST? 65
The Pieces of a RESTFul Web Service 66
Introducing JAX-RS 67
Basic Concepts: Resources and Applications 68
A JAX-RS “Hello World” in WebSphere Liberty 68
Creating the WebSphere Liberty Server 74
Starting the Server and Testing the Application 78
More JAX-RS Annotations 80
Testing the New Example 82
JAXB and More Interesting XML-Based Web Services 82
The JAXB Annotations 83
A Trivial DAO (and Its Use) 86
JSON Serialization 88
A Simple Transaction Example with JAX-RS 88
Handling Entity Parameters with POST and the Consumes Annotation 90
The Use of Singletons in Application Classes 91
Testing POST and Other Actions with RESTClient 94
More on Content Negotiation 95
Introducing the JAX-RS Response 97
Hints on Debugging: Tips and Techniques 98
Simple Testing with JUnit 98
RESTful SOA 101
Summary 102
Endnotes 102
Chapter 5 Application Architecture on the Glass 103
Why Well-Designed Applications Matter 103
Defining a Client-Side Architecture 104
Responsive Design 109
Client-Side Architecture 114
Application Controller 115
Model-View-Controller 116
Error Logging and Management 120
Data Storage and Caching 121
Configuration 121
Introduction to the Dojo Toolkit 123
Dojo 124
Dijit 124
DojoX 124
Util 125
Why Use Dojo 125
Asynchronous Module Definition 126
Future of Dojo 129
Using Dojo in Your Application 130
Section: HTML Declaration 132
Section: Styling 132
Section: Configure Dojo 132
Section: Load Dojo 134
Section: Initialize Application 134
Section: Body Content 135
Creating Your Own Widgets 136
Building the Application 140
Summary 166
Chapter 6 Designing and Building RESTful Applications with Modern Java EE 167
Modern Java EE 167
EJB 3.1 and CDI 168
JPA 171
Application Architecture for Modern RESTful Systems 172
Division of Labor: Defining the User Model and REST Interfaces 174
Application Layers 179
Building the Application 185
Loading the Example and Setting Up Liberty 185
Test-Driven Development 190
Building REST Services 195
Domain Model 201
Building DAO and Business Logic 205
Running the Application 209
A Discussion on Choices 210
Summary 211
Chapter 7 Introduction to IBM Worklight 213
What Is IBM Worklight? 213
Elements of IBM Worklight 213
The IBM Worklight Product Family 214
Developing with IBM Worklight 215
IBM Worklight Deployment Architecture 216
IBM Worklight Server Architecture 221
The Structure of a Worklight Application 223
What This Means for You 224
Summary 226
Chapter 8 Building a Worklight Hybrid App with Open Source Frameworks 227
Design for the Hybrid Application 227
Overview of Frameworks 228
jQuery 229
jQuery Mobile 229
Require.js 229
Backbone and Underscore 230
Handlebars 230
Building a Hybrid App with Worklight 230
Setting Up the Project 230
Worklight Adapter Code 233
Worklight Hybrid App Folder Structure 240
Examining the Application 242
Running the Example 255
Summary 260
Chapter 9 Testing and Debugging 261
HTML 261
JavaScript 262
Global Variables 263
Asynchronous Module Definition (AMD) 263
Context 264
CSS 267
Data 269
Unit Testing 269
The Browser as a Test Platform 272
Exploring Chrome’s DevTools 273
Essential Browser Plug-ins 279
IBM Worklight Specific Concerns 281
Disabling AppCache for Mobile Web Apps 281
Disabling Security for Cross-Domain Ajax in Mobile Apps 283
Remote Debugging 284
Safari Remote Debugging 284
Chrome Remote Debugging 285
Online Code Snippit Runners 285
Summary 286
Chapter 10 Advanced Topics 287
Understanding Where Your Application Fits 287
Achieving Reliability Through Clustering 292
Versioning 292
Versioning in the URI 293
Versioning in the Header 294
Mechanisms for Improving Performance 294
Pagination 295
Caching Overview 296
Response Caching 297
Server-Side Caching with WXS 298
Security Issues for Modern Web Applications 302
Summary 304
Endnotes 305
Chapter 11 Key Takeaways of Modern Web Development 307
The Engaging Enterprise 307
Mobile-First Development 308
Web APIs 309
Polyglot Programming 310
Cloud Computing 310
Summary 313
Endnote 313
Appendix A Installation Instructions 315
Development Machine Installation 315
Installing Java Runtime Environment, v1.7 316
Installing Eclipse Juno IDE, v4.3 317
Installing IBM WebSphere Liberty Profile Developer Tools, v8.5.5 318
Installing the Source Code for the Book Examples 319
Optional Development Tooling for Mobile Web Apps 321
IBM Worklight Studio v6.0 321
Android Development Tools and Eclipse Plug-in 324
OSX XCode IDE 327
Server Installation 328
IBM WebSphere Liberty Profile, v8.5.5 329
Apache Derby, v10 330
Downloading and Installing Example Source Code 333
Summary 333
Index 335