Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-1800

Generate a full JSON/REST interface via an entity's controller



    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 1.1.0.RELEASE
    • Fix Version/s: 1.1.1.RELEASE
    • Component/s: WEB MVC
    • Labels:
    • Environment:
      Windows 7; STS 2.5.0 RELEASE


      As I understood, the ROO JSON support generates some JSON methods in the controller via the controller's aspect file. But currently, only a subset of a full JSON/REST interface (READ, CREATE, UPDATE, DELETE) is exposed.

      I suggest to provide a full interface to be able to

      *) Read one element (via GET specifying the id of an element)
      *) Read all elements (via GET)
      *) Read a number of elements via a finder (via GET specifying a finder and arguments)
      *) Create one element (via POST specifying a single JSON element)
      *) Create a number of elements (via POST specifying an array of JSON elements)
      *) Update one element (via PUT specifying the id of an element)
      *) Update a number of elements (via PUT specifying an array of JSON elements)
      *) Delete one element (via DELETE specifying the id of an element; this method is already in the controller's aspect - no specific JSON method needed)

      via corresponding JSON endpoints.

      I implemented all those methods in the controller attached. The first couple of methods is currently generated by the aspect, but I commented the out in the aspect file to have them modified in the controller to fit into the schema proposed above.

      Please also note that the finder's JSON endpoint has to be generated every time a finder is added by the user - currently no JSON endpoint seems to be generated when finders are added.


        1. json-examples.txt
          2 kB
        2. NewsItem.java
          0.7 kB
        3. NewsItemController.java
          4 kB

          Issue Links



              sschmidt Stefan Schmidt
              jwr Johannes Weidl-Rektenwald
              0 Vote for this issue
              0 Start watching this issue