labs / tiddlers / content / labs / lab10 / _Labs_10_Sale Web Service

The sale JSON being POSTed to the /api/sales URI should be compatible with your Java Sale domain class. This means that Gson will be able to use the JSON to create a Java sale object from the request body.

The Jooby route listening for POST requests to /api/sales should:

  • Get the request and convert it to a Sale object (use the /api/register route in the customer module as a guide).

  • Print the sale to the console to check that the fields are all set. If you see nulls for important fields then you have probably used the wrong field name somewhere in your HTML or JavaScript. Note that the Customer ID and Sale ID are both generated by the database, should be null at this point.

    Add a complete toString to your Sale class if you haven't done so already so that you can print the entire sale details.

  • Save the sale using a sale DAO. The next section covers how to implement the DAO save method.

If you have completed the <

> button then you should be able to see the complete sale details appear in the NetBeans output pane when you click the button.