I'm debating whether to use Seam, Wicket, JSF or GWT as the foundation for my presentation layer in a Java project.
I narrowed my selection of Java web frameworks down to this subset based on job market considerations, newness of the technology and recommendations from other S.O. users.
What factors should I take into consideration in deciding among these?
I've used GWT since version 1.4 and JSF since the 2.0 spec came out.
GWT is a client-side framework, it generates JavaScript from Java. Your architecture would be a pure client-server, which means:
- Best to use coarse-grained services
- All objects that travel to the client side should be fully serializable (it means there's no lazy load, or OpenSessionInView pattern)
- Since GWT 2.0 you can design your gui using xhtml, which is much easier in regards to styling & structuring HTML
- GWT tends to favour good architecture, if you mess it up it will be bad to refactor
-
Perfect History (browser back button, bookmarkable urls) support is hard, you probably have to roll your own, although it's easy to hack something right up front
JSF is a component-based framework, with a view-first design (code-behind if you like):
- It's easier to do some type of webapps (stateful, like shopping cart)
- JSF+Seam have suport for conversations (think wizard-like pages that maintain state across several pages)
- You can implement OpenSessionInView, depending on your stack. It's probably not recommended if you use EJB for service/business layer
- JSF2 has superb support for AJAX, and with a component suite like RichFaces you can build nice webapps
- But if you want exquisite javascript behaviour, you'll have to write some javascript
- JSF tracks the current UI state in client or server-side. This is a tradeoff between network traffic or server memory.
Resume:
-
GWT is more adequate for web applications (think gmail) that require the best client-side performance. It's easy to write custom components (you write Java) and since your server-side is just a service layer you can be fully stateless on the server side.
-
JSF is more adequate for mostly CRUD applications that are better suited for component-oriented stuff: think a hotel/flight reservation system, an online store with a shopping cart, etc
The only one of those I've used is JSF, so I won't be able to give you feedback on the others, but here's my take on JSF. In my experience, the minute we converted from JSF in JSP to JSF in facelets, life got MUCH easier, so I'll focus around facelets. Also, It looks like Seam and JSF are not mutually exclusive.
Pros:
- Creating facelets xhtml components is simple, which promotes re-use.
- Decent templating abilities using built in tags like ui:insert, ui:include, and ui:decorate
- Simple access to Spring beans through faces-config
- XHTML based so web developers unfamiliar with java can still be effective
- Good widget library available in tomahawk/trinidad
Cons:
- Post requests only. This can make bookmarking difficult.
- Not as built-in ajax-y as GWT, but this may be fixed if used with Seam
I'm by no means an expert in JSF/Facelets, so I'm sure there are others I've missed. Hopefully someone else will also elaborate.
Update for JSF 2.0:
- Has even better re-use capabilities with composite components
- Widget libraries for 2.0 include primefaces and mojarra scales
- Allows get requests and bookmarking
- Has built in Ajax support
- See http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/ for more on JSF 2