0

The Spring Boot OAuth2 authserver sample app at this link uses FreeMarker templates for its views, which include login, and authorize. The main application class for the app is at this link.

What specific changes need to be made to the code in the authserver app in order for the login and authorize views to be served in AngularJS INSTEAD OF FreeMarker?

Would the rigidly-defined server-side processing in this particular app require that two separate Angular single page applications be created, one for each view? Or could one AngularJS app handle both the login and authorize views, plus other views that might be added later? How would this get set up?

FirstOfMany
  • 185
  • 2
  • 7
  • AngularJS and Freemarker are orthogonal. Freemarker generates HTML pages. AngularJS operates on HTML pages after they're already served. – chrylis -cautiouslyoptimistic- Jul 14 '16 at 02:44
  • @chrylis Should we then interpret your comment to mean that each FreeMarker view would correlate with its own single page application (SPA) in AngularJS? Alternatively, is there a way to set things up so that there is only one AngularJS app instead of many SPAs? – FirstOfMany Jul 14 '16 at 03:32
  • That's one approach, unless you're loading fragments of HTML via AJAX. Generally, with an Angular application, you'd generate a single HTML page with the startup parameters with Freemarker or another template technology, and everything else happens on the Angular side. – chrylis -cautiouslyoptimistic- Jul 14 '16 at 03:39
  • You answered the question. Spring Boot looks for views in any folder named `resources`, `templates`, or `static`. Also, `viewControllers` in the main application class map view files to api endpoints. Therefore, following your suggestion, I simply 1.) renamed the `templates` folder to become `static` folder, 2.) renamed `login.ftl` to become `index.html`, and 3.) changed `registry.addViewController("/login").setViewName("login");` to become `registry.addViewController("/login").setViewName("index");` in `AuthserverApplication.java`. The login view works same, but now able to add AngularJS code – FirstOfMany Jul 14 '16 at 22:51
  • @chrylis If you want to write your suggestion as an answer, I would be happy to mark it as accepted and +1. – FirstOfMany Jul 14 '16 at 22:52
  • The issue of how to have one AngularJS app instead of 2+ can become a separate question later. At least for now I know how to change from FreeMarker to AngularJS based on your comment. – FirstOfMany Jul 14 '16 at 22:53
  • The question itself is still a bit unclear, and I'm not sure I can translate this thread into an answer that will be useful for future readers. If you can clarify (maybe roll your comments up into), I'd be happy to try. – chrylis -cautiouslyoptimistic- Jul 15 '16 at 02:50

0 Answers0