Greg
Greg

Reputation: 442

Spring Roo 1.2: Using Spring Roo just to create controller, no jspx file

I am trying to create a RAD jquery mobile application generator that sits on a roo generate gae project. I've written the generator code that finds all jpa entities and then creates a full jquery mobile application over the found entities utilizing REST/JSON services created with roo. Similar to what roo web mvc does with the dojo web app. I'm trying to find a way to only create the REST/JSON controller and not all the view stuff (jspx/tagx/tiles/etc) as they do not deploy to gae. Does anyone know if this is possible without editing the roo plugin directly?

project --topLevelPackage com.testpackage --java 6 --projectName testproject
persistence setup --provider DATANUCLEUS --database GOOGLE_APP_ENGINE
entity jpa --class ~.domain.Company --testAutomatically
field string --fieldName name --sizeMax 50
service --interface ~.service.CompanyService
json add --class ~.domain.Company
controller all --package ~.controller.CompanyController <---- creates the controller and all the unwanted web stuff

Any thought would be greatly appreciated...

Upvotes: 0

Views: 1232

Answers (2)

bonh
bonh

Reputation: 2956

I'm happy to report that this is possible with Spring Roo 1.2.5.

project --topLevelPackage com.example.jukebox
jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY 
entity jpa --class ~.domain.Song
field string --fieldName title
json add 
web mvc json setup
web mvc json all
exit

Spin up a Jetty server with mvn jetty:run.

Now, you can POST a song:

curl -X POST -d '{"title":"Ride Around Shining"}' -H "Content-Type: application/json" http://localhost:8080/jukebox/songs

Or GET a list of all songs: curl http://localhost:8080/jukebox/songs

[{"id":1,"title":"Ride Around Shining","version":0}]

Or GET a song by id: curl http://localhost:8080/jukebox/songs/1

{"id":1,"title":"Ride Around Shining","version":0}

Upvotes: 1

Greg
Greg

Reputation: 442

I ended up forking the roo web addon source code. Made the modification so the jspx files were not copied over.

Upvotes: 0

Related Questions