View Full Version : Spring Roo ExtJS PetClinic Example

8 Mar 2011, 10:15 AM
Not sure if anyone would benefit from this but thought I would post it just in case:


I put it the source code up on github.

This is the attached README in the root of the source code:

Changes to PetClinic Roo Example
Spring ROO 1.1.1.RELEASE

1. clinic.roo
1.1 add json all to end of script
1.2 change employedSince to java.util.Date from java.util.Calendar (was getting an error when deserializing the json into a Calendar type, didn't have time to debug)
2. created new tiles template src/main/webapp/WEB-INF/layouts/extjs.jspx
3. added new template to tiles config src/main/webapp/WEB-INF/layouts/views.xml
4. created new index_extjs.jpx that uses above template : src/main/webapp/WEB-INF/views/index_extjs.jspx
5. added new configuration for index_extjs.jspx to use new template : src/main/webapp/WEB-INF/views/views.xml
6. added static view for index_extjs.jspx : src/main/webapp/WEB-INF/spring/webmvc-config.xml
7. installed ExtJS : src/main/webapp/js/extjs-3.1.1
8. created ExtJS application : src/main/webapp/js/overrides, src/main/webapp/js/PetCompany, src/main/webapp/js/PetClinic
9. Added JsonObjectResponse.java wrapper : src/main/java/com/springsource/petclinic/extjs
10. Modified all Controllers to wrap their responses using JsonObjectResponse

I didn't have time to put any code in the finders, but I am using one of the finders to link the Owners to pets, so there is an example in there.

I barely made any changes to the ROO generated code, basically just what I mentioned in the README.

I also didn't touch any of the ROO generated front end, I made the Banner Link (which by default goes to the root of the application) to switch between the ExtJS front-end and the ROO generated front end.

So if you got to http://localhost:8080/petclinic you see the normal PetClinic frontend. If you click on the ROO banner, or go to http://localhost:8080/petclinic/index_extjs it will switch to the ExtJS front end.

Also note, I threw this together pretty fast, and I didn't worry about formatting.

This should be a good starting point for anyone looking into ExtJS and Spring Roo. I found it rather straight forward, once you get used to ExtJS.

I pulled information from the following sources:

ExtJS In Action by Jesus Garcia http://extjsinaction.com/
Jesus Garcia's Blog http://tdg-i.com/
Saki's Blog : http://blog.extjs.eu/
ExtJS Api Documentation : http://dev.sencha.com/deploy/dev/examples/
ExtJS Samples & Demos : http://dev.sencha.com/deploy/dev/examples/
Spring Roo Forum :http://forum.springsource.org/forumdisplay.php?f=67
Sencha ExtJS Forum : http://www.sencha.com/forum/forumdisplay.php?39-Ext-JS-Community-Forums-3.x

Hope this helps

30 May 2011, 7:03 AM
Hi i need help in creating a dynamic JS file. In the above petclinic example i see a common jspx file but with differenct JS file when i use in Spring Roo. As Spring Roo creates its own Controller, jspx files when we select a scafold controller, Can u please help me creating a dynamic JS file so that the project becomes more dyanamic with less maintainence of code.

8 Jun 2012, 2:52 PM
This is good. Thanks for posting. I am working on Sencha Touch application with json proxys.Can I reuse anything from this app or do you have any quick tips to develop the interface faster.

This is what I am thinking.

I will stick to scaffold controllers now for entity CRUD operations
Will use json add.
I am not sure if json addon will support all sencha touch store apis as is without any changes. Any tricks you know ?

Thanks in advance