Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which UI to use with spring

 
Tomasz Ducin
Greenhorn
Posts: 10
Hibernate Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In spring web mvc I couldn't find some fundamental layout features such as decorating templates (separating columns, footers, headers, etc. into reusable jsp files). I read several opinions on the web that the best UI to use along with spring web mvc is apache tiles. Some said that it can also be sitemesh.

Lately I've been trying to use Apache Tiles with my spring project and I'm somehow disappointed, because it is not as developer-friendly as I expected. Tiles implement composite view, whereas sitemesh implement decorator pattern. This is fundamental difference, since decorator is easier for developer to use and - imho - more flexible (e.g. it enables to override variables in the child views, not in xml definitions). I would like to get your opinions on where Tiles (a composite-view-based templating engine) can be better than a decorator pattern? And what do you use?

Yep, as you can see, I'm a JEE newbie ;) I've been working in PHP until now and I must say that almost every PHP templating engine has all important features built in (no need to include .tld files). In JEE you've got to use JSP + JSF or Tiles or Sitemesh - I wonder why isn't it just all included in spring web mvc? I can't imagine a big website that doesn't have a well-implemented templating engine (e.g. inheritance) - this forces the developer to choose several tools to build only the UI part of a system (django, ruby on rails, symfony - they cover all those topics all by theirselves).
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go here and scroll down to the part titled Composite View vs. Decorator

http://tiles.apache.org/tutorial/pattern.html


Spring MVC handles view resolution. The view implementation is left up to the developer, I would rather not have to choose one. I appreciate the fact that different view implementations are better for different use cases. Whether I choose JSP, static HTML, Freemarker, Velocity, JSF etc. I have that choice. A lot of thought has gone into the development of each of these and Spring MVC does not look to redo that work but rather to make it as painless and flexible as possible for the developer to use any of them.

Besides rendering a view there is the problem of mapping requests to a handler (while remaining flexible), resolving the view to render, handling things like locales, and themes, data binding, validation, form uploads etc. This is the type of thing Spring MVC focuses on. It really revolves around the Dispatcher Servlet which is an implementation of the well known J2EE front controller pattern.


Hope that helps
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, me personally. I dislike Tiles very very much.

There is Thymeleaf which a lot of Spring guys use and really like. My friend Michael Isvy wrote a great post about it here
http://blog.springsource.org/2012/10/30/spring-mvc-from-jsp-and-tiles-to-thymeleaf/

Now I personally don't like jsp pages or any server side rendering of pages. I prefer the Single Page Web App with AJAX/REST calls to my serverside, where the server side only returns json data (after the initial index/home request) Then on the client side I use ICanHaz.js, which is built on top of Mustache. It is a very simple to use templating engine. Probably more similar to what you had in PHP.

Mark
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Funny you bring that up Mark. I was thinking for awhile now about reading http://www.manning.com/mikowski/
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill Gorder wrote:Funny you bring that up Mark. I was thinking for awhile now about reading http://www.manning.com/mikowski/


Yeah, I think today's good websites are moving away from the old style Enterprise Java applications with the Servlet/JSP spec and moving towards more cleaner approaches.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic