Chapter 8. Building a single-page JavaScript application with JSON

 

This chapter covers

  • Defining a RESTful web service
  • Sending JSON to the web browser
  • Parsing JSON from an HTTP request
  • Converting between JSON data and Scala objects
  • Validating JSON data
  • Authenticating JSON web service requests

In this chapter, we’re going to reimplement part of the sample application from chapter 2 using a more modern JavaScript client application architecture that allows you to make more responsive web applications with richer and more interactive user interfaces.

We’re going to use Play to build the server for a JavaScript application that runs in the browser. Instead of using view templates to generate HTML on the server and send web pages to the browser, we’re going to send raw data to the web browser and use JavaScript to construct the web page.

Our goal is to reimplement the product list application so that we can edit product information in place by editing the contents of an HTML table, and have changes saved to the server automatically, without submitting a form.

Figure 8.1 shows a table of products that allows us to edit values by clicking and typing, adding uncoated to the first product’s description in this case.

Figure 8.1. Editing the first row of a table of products

8.1. Creating the single-page Play application

 
 

8.2. Serving data to a JavaScript client

 
 

8.3. Sending JSON data to the server

 
 

8.4. Validating JSON

 
 

8.5. Authenticating JSON web service requests

 

8.6. Summary

 
 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest