I am starting a new pretty big webapp and I am using Spring MVC for complete MVC architecure and I really don't want to change that. On top of that I am looking for a view technology and finally closed with JSF as JSF/facelets is in official EE specification which means they will be the future. Plus prime faces looks promising in acheiving good UI. I know JSF is a MVC framework and I just want to liverage its view part to reduce the development time and at the same time acheiving good and flexible responsive UI
But I went through several posts on StackOverflow itself which prohibits the use of Spring MVC + JSF. E.g, this one
This question was answered in 2011 and now new Java EE specification also got released and many changes has happened. Is this point still stands that we should not use JSF+Spring MVC? If it is true, then what are the replacements. One option that looks good for me is Thymeleaf, but only thing that is troubling me is that will it be a good idea to neglect an official specification?
JSF can probably be integrated (I'm not very sure, see the links at the end of my answer) with Spring MVC but it does not look a very good fit to me. Primarily since JSF is component based, while Spring MVC is action-based. In Spring MVC, the controllers do the processing and can pass the results to anything that renders the view (jsp, html, thymeleaf, apache tiles etc.). Thymeleaf is a good option and I like its approach to templates.
Other alternatives I would suggest to look instead of JSF:
JS frameworks:
I personally prefer this for my projects and there are tons of options to choose like jQuery/jQuery UI, ExtJS etc. for creating you views. You can combine these and make their elements work with fluid frameworks like Bootstrap so that they behave nicely on all screens sizes (not sure how PrimesFaces/RichFaces components behave on all devices)
Frameworks that compile to JS:
Here you have two good frameworks to choose from - Vaadin and GWT. I've used only Vaadin and not GWT so will not comment much on it. Choose this if you don't want to directly fiddle with javascript.
It is not true that only if you use the official Java EE spec you can be in sync with the future. HTML5, JS frameworks etc. are as much the future as JSF is, if not more! Ofcourse JSF of late looks good too (I have not made any production code with it yet, nevertheless have explored it in hobby projects) but you are better off using it on its own with PrimesFaces/RichFaces and not combine it with Spring MVC.
On a middle ground, you can use Facelets instead of Thymeleaf for templating views in Spring MVC. On the other side, you can use JSF with Spring DI, but as I said earlier don't mix JSF and its component libraries with Spring MVC.
Update: Just in case if you absolutely want to try it, here are some links:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With