Chapter 7. Developing CRUD Operations and Validations

Until now, we have seen how to build the read-only HTTP methods of an API. These methods in Spring MVC Controllers required you to master, or at least understand the presentation of a few techniques. Developing non-readonly HTTP methods raises a new set of underlying topics. Each of these topics has a direct impact on the customer experience and therefore each of them is important. We introduce the following four recipes as a frame to cover the subject:

  • Extending REST handlers to all HTTP methods
  • Validating resources using bean validation support
  • Internationalizing messages and contents for REST
  • Validating client-side forms with HTML5 and AngularJS

Introduction

Developing CRUD operations and validations at this stage turns out to be one of the topics with the widest spectrum.

Our application will be transformed in many ways, from the transaction management standardisation to the internationalization of errors (and content), passing through the REST handlers, HTTP compliance.

In line with the previous chapters and with the global strategy of this book, we are focusing on how Spring MVC plays a key role in today's and tomorrow's best practices in regards to scalability and Microservices communications. It is a hard choice to decide skipping bits, but the Framework keeps adapting itself to new designs and challenges. This book tries to present a consistent integration of Spring MVC in a modern, sustainable, and scalable application.

Four recipes are presented here. The first one transforms two controllers to support the CRUD operations for their respective resources. Doing so requires a review of the database transactions and a review of the HTTP specification.

This chapter presents two validation strategies supported by Spring MVC. Since validation errors are often meant to be rendered in more than one language, we have made sure that our application supports internationalization. We briefly see how AngularJS can be used in this perspective and how it can be used to process frontend validations that are always necessary to constrain the customer experience into the reality of the business-specific data management.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset