36
votes

I'm in the "technologies selection" phase of a small, single-page web application that will be heavily-based in AJAX, and which will report to a Java backend.

In a previous question I posted several weeks ago, the SO community at large felt strongly that I would be better off going with a Spring MVC-based web app than with something in JSF. Since Spring is request-oriented, and JSF is component-oriented, it would only make sense to use Spring for something that is going to be getting a lot of asynchronous requests.

If I were going the JSF route, then my next set of decisions would be whether or not to use so-called UI component libraries for the view technology, such as PrimeFaces, IceFaces or MyFaces.

So, I'm wondering: Does Spring MVC have anything similar to, say, PrimeFaces (or its likes) for creating the view component for my page(s)? I know its not component-based, but I'm not all that familiar with Spring MVC's web platform and was wondering what are some de facto standards (if any) or typical technology stacks that Spring web developers use for constructing nice web pages.

And, if Spring just uses run-o-the-mill template engines, would something like Freemarker suffice?

I guess this is a "best practices"-type question for a budding Spring web developer.

Thanks in advance!

4

4 Answers

21
votes

Typically, the value so-called UI components lies in how they keep track of user interactions on the server side by integrating with a stateful framework.

Since you have decided to go for a request oriented framework, it would make more sense to use some well-known client-side JavaScript libraries instead. Popular choices include:

Personally, if I don't need a lot of standard prebuilt widgets, I like Backbone.js + underscore.js + jQuery. I don't like Google Web Toolkit since it feels like writing a pidgin JavaScript, and at that point I prefer to write JavaScript directly.

7
votes

Yes, JSF is component oriented and Spring MVC is request oriented. I recommend you to have a look at Thymeleaf Template engine, which is a complete replacement for JSP Engine .... Thymeleaf Features are:

  • It allows natural templating.
  • HTML5 support
  • Higher performance by utilizing in memory caching

Click here for more

1
votes

Additionally apart from the things mentioned by Ludovico Fischer, if we consider the same question in now a days tech world than you can use one of the most power full thing of recent world : Angular. There are 2 sample scenario's.

  1. If your architecture is full client side: The integration is very natural for it. Spring MVC expose your service as a REST (JSON / XMl ... ) and your client application with Angular JS consume your JSON. Here the war application (Spring mvc ) must be deployed in a Servlet Container (Tomcat) and your client application can be deployed in the same server or in another server Nginx , Apache etc..
  2. If you want to keep page generation in the server side and only use AngularJS for some nice DOM manipulation so your code must be deployed in the same war (WEB-INF). Mixing the two approachs is not always a good idea. You can try thymeleaf to stay in server side page generation.

    Thus in this way you can have simultaneously the cool featuresof angular like templating, testability and clean view code.

0
votes

Here is another approach (Not JSF) to let Spring MVC to work with ZK UI components - Rich Web Application with Spring MVC CRUD Demo

In that article, it used Spring MVC controller to communicate with ZK UI components. (all in Java code)