angularjs - with - java single page application
Basic Example and best practice of AngularJS Java EE web app (2)
I'd only call this a valid question because there are simply so many ways to do web development these days (and yes, this same sentence would have been just as valid a year back). However, I would rather try answer a few underlying questions instead.
Presentation-oriented: A presentation-oriented web application generates interactive web pages containing various types of markup language (HTML, XHTML, XML, and so on) and dynamic content in response to requests.
Service-oriented: A service-oriented web application implements the endpoint of a web service. Presentation-oriented applications are often clients of service-oriented web applications.
AngularJS is a front-end user interface framework. By the above definitions, this means Angular falls into the presentation-oriented category, without any server-side processing of it's own.
As for using this "in a Java EE app" as the question puts it.. Well, put quite simply, you don't. If you did try, you'd end up with either one
jsp page spawning the entry point for your
ng-app, or you'd end up with an
ng-app that gets constantly reloaded as other
jsp pages are loaded into the browser. Neither of these make use of technology to their full potential.
Your best bet is to set up a service-oriented Java EE application with a RESTful API, which your presentation-oriented AngularJS application would consume and present for the end user.
For what it's worth, this video tutorial gives a nice clear overview of something like this in action.
If anyone has used AngularJS in a Java EE web app, then we will be grateful if you can provide any pointers/ examples of it.
What are the best practices, what is the ideal structure, design etc. Any weblinks also will be helpful.
Since this is a very general question I'll answer it as such. There was a talk at jFall 2012 which demoed a very basic application with Java EE 6 and AngularJS which can be found here: https://github.com/teunh/jfall2012
I've been working on a school project which uses AngularJS as a frontend - JAX-RS as the restful interface and the basic backend logic in beans and database persistence with hibernate. I won’t be able to open source this project at the moment since it’s still a work in progress.
My experience and my message to you is that it's very easy to build a Java EE backend with an AngularJS frontend if you keep a restful interface in mind.