I like Angular. I've been playing with AngularJS for a few weeks now and I have to admit, it's cool. From a UI standpoint, it can really make browser based applications responsive.
Of course, there are some problems with AngularJS if you're a seasoned JSF developer, one of which is the lack of obvious server-side handling capabilities that compete with some of the popular Java based, web tier frameworks. Yes, I know, Angular applications simply have to call RESTful web services, and as Java programmers, we can just write some JAX-RS code and handle the incoming data. But still, it's not as elegant as JSF.
Avoiding the Haitian Vodoo
I will admit to my bias. I like JSF. I like the way HTML forms are mapped to backing beans. I like the lifecycle stages that do things like validation and conversion, and I like the way managed beans can be used to very easily update content spots on a page. And yes, I know that JAX-RS can do similar bean mappings using the @form tag and a little bit of Haitian Voodoo, but still, I like how JSF does it. And I also like how JSF integrates with the whole Java EE ecosystem.
As I've fiddled around with AngularJS, I can't help think about how neat it could be if we could combine AngularJS and JSF. It actually wouldn't be too hard, because the two have very separate responsibilities, although JSF might have to be involved with updating the AngularJS model, as opposed to a JSON over HTTP interaction. Obviously I'm not the only one to have had that idea, as the concept has already been written about, and a little project named AngularFaces has been attempted to combine PrimeFaces with AngularJS. Reza Rahman wrote an interesting article about it: JSF + AngularJS = AngularFaces
Anyways, I'm going to make an attempt of my own, without allowing those other projects to bias my angle of approach. Look for some tutorials coming out in the mean time that demonstrates how cool a merger of the two would be. Who knows, maybe this will be the next, hot, open source project?
If you're not up to speed on Angular, TheServerSide has run a few articles on the topic:
We've also run a few JSF tutorials, namely ones about templating with JSF and integrating Ajax calls into the Facelets framework. It's actually a pertinent discussion, because as responsive as Angular is, when you start doing Ajax calls within your JSF applications, the whole thing becomes pretty fast, so the need to use something like AngularJS becomes minimized:
- An introduction to template building with Facelets, CSS, HTML and JSF 2.2
- Turning a web page into a JSF 2.0 template with Facelets
- Creating pages based on a JSF template: Using the Facelets ui:define tag
- Template based web design with JSF Facelets: ui:insert versus ui:include
- Integrating Ajax into your Facelets pages: Death to JSF's request-response cycle
- Completing the Ajax based Facelets application
You can follow Cameron McKenzie on Twitter: @potemcam