Skip to content

jeremyg484/dojo-json-rest-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo: Connecting DataGrid to a Store backed by Spring @MVC

This is a simple demo app to show connecting the new dojo.store.JsonRest object store to a Spring @MVC RESTful controller.

The main source files of interest are:
https://github.com/jeremyg484/dojo-json-rest-store/blob/master/src/main/webapp/demo.html <- The Dojo grid client
https://github.com/jeremyg484/dojo-json-rest-store/blob/master/src/main/java/org/springsource/tutorial/web/USStateController.java <- The Spring @MVC controller backing the JsonRest store

This is a WIP intended to test how easily we can support JsonStore with Spring MVC.  There are a couple of issues at the moment:
1. JsonStore doesn't set an Accept header when is issues PUT and POST requests, thus the wrong handler method (the one that produces HTML) is getting selected.
2. JsonStore sends its "sort" parameter in the form of "sort(+fieldName1,+fieldName2,-fieldName3,...)", thus the entire thing becomes the parameter key.  This is inconvenient to handle in Spring MVC as it requires dropping down to HttpServletRequest and iterating through parameter keys to find the one beginning with "sort", as opposed to being able to use the @RequestParam handler argument annotation.

The configured Maven setup should allow the full WAR to be built via 'mvn install', and optionally to be run in an embedded Tomcat instance via 'mvn tomcat:run'.

When running locally on Tomcat, the Dojo grid demo page is accessed at http://localhost:8080/dojo-json-rest-store/demo.html

Running the app locally requires a local MySql instance with a database named 'dojoTest'.  See /src/main/resources/database.properties to edit connection settings for MySql.

This app can also be run on Cloud Foundry without any required changes.  Just run 'mvn install' and then 'vmc push {app_name} --path target/', and bind a MySql service to the app when given the choice.

The base application was generated with Spring Roo, thus it also includes the usual Roo HTML scaffolding.  The JsonRest store operations are supported in this case by explicitly adding more specific @RequestMappings to handle them. 

About

Example of backing dojo.store.JsonRest with Spring @MVC controllers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages