The project downloadable below is an answer to a question repeated in this blog (Spring 3 MVC – Adding Objects to a List element on the fly at form submit – (Generic method))
“How can I submit nested lists of objects?”
The answer is AJAX and JSON.
A very good approach to this is with AngularJS and Spring as demonstrated here.
When the page loads it makes an AJAX call to the server to fetch the model.
The model is bound on the page using AngularJS.
The controls (buttons and input fields) on the page allow the model to be edited.
The model can then be sent to the server via AJAX where it can be persisted. The updated model is returned to the client where it is again bound using angularJS.
The application looks like this
This is a Maven project so just navigate to it using your IDE, open it and run it.
This blog demonstrates how to process JSON using Spring 4 Web MVC.
Spring uses Jackson for JSON parsing. Jackson is configured to ignore extra JSON properties that do not match properties of the bean being populated at the @Controller request end-point method.
This blog demonstrates populating complex objects n levels deep thus overcoming some difficulties encountered as per many of the comments in this blog.
This provides for:
- A far better user experience as there is no page load. Feedback is immediate.
- Ease of development
- Ease of validation handling
- Support for complex forms
- Code portability (think HTML5 clients and single page applications)
Continue reading “Spring 4 Web MVC – JSON Handling”
This blog will go through the steps required to setup a basic Spring 4 MVC web application using Netbeans and Maven. The Spring 4 project will be configured using annotations and plain Java rather than XML.
It is a step by step guide to getting up and running quickly. There are plenty alternative methods to doing this but this one is simple, lightweight and to the point. A maven project is available for download at the end of this blog.
Continue reading “Spring 4 Web MVC – Hello World using Annotation and Java configuration with Netbeans”