I’m working on a web application with a Spring Roo REST API backend and a Dojo single-page client app. Spring Roo provides a handy admin interface (with Web MVC) out of the box, so I’d like to keep that accessible for administrative duties.
However I’d like the Dojo app to be decoupled from the server application as possible. The server is a platform for which we expect new client applications to be developed, so I’d like to develop the ‘official’ client web app in isolation.
What is the best (or even just one good) way to structure the application code? It’s easy to leave the server alone as an API and admin interface, but where does all the Dojo JS live? It works okay when it’s in the Spring webapp directory, but gets complicated quickly as soon as the structure gets more complex or is moved anywhere else (Spring URL mappings are still awfully opaque to me). Ideally it could be hosted locally on a development machine, which introduces all the cross-domain JS issues as well.
Since the latter versions of the dojo toolkit came out, we dont really have to distinquish between same- and cross-domain javascript modules. Using the dojo loader, you can pull in modules from everywhere.
I would suggest creating a namespace of your own, e.g.
com.yourmoduleand then reference its location in the configuration. For instance; you could create a host, ‘arbitrary.domain’, for the js-application and put it in ‘/com/yourmodule/’ folder there. The com.yourmodule.application contains the bootstrap and initialization of your app. This ofc would be in the file ‘/com/yourmodule/application.js’.The first require (or via dojoConfig) you specify the package declaration, pointing to the namespace location, somewhat like this – following the above sample naming conventions.