Running spring MVC along side of JSF - jsf

I want to write some new functionality in spring MVC, the problem is that the current site is written in JSF 1.2.
It does use spring 2.5 application context, but thats all.
I am thinking i can drop in spring MVC, write a single page in it, and then see what kind of hoops ill have to jump through to be able to have seamless sessions between spring mvc and jsf.
can someone offer some wise words to me about this venture?

The session will not be a problem. It will be the same session, because it's a lower-level concept than JSF and spring-mvc.
The URL mapping of the respective servlets (the dispatcher servlet and the faces servlet) might be a problem. Your faces servlet would be mapped to *.jsf, and then your dispatcher servlet should be mapped to something like /mvc/*
The question remains whether mixing frameworks like that is a good option. I'd rather suggest using JSF everywhere in this project.
If you need some RESTful services, you can use spring-mvc, or you can use some JAX-RS provider, like CXF or RESTEasy.

Related

Why is JSF considered MVP but not MVVM framework

From the wiki page about JSF I've learnt that it's considered as an MVP framework. But I cannot realy understand why.
Actully, beans do not contain a reference to View in themselves. There's also a data bidinig mechanism between Facelets and Managed beans.
So I would say that Managed Beans are more ViewModel than Presenter, as that Presenter usually contain a View interface in itself like in that example.
QUESTION: Why is JSF considered MVP but not MVVM framework?
MVVM is mainly a desktop application oriented pattern. When considering MVVM in web application perspective, there would be a controller in the client side. JSF doesn't have such one. When still speaking about web applications, if you were using e.g. Spring MVC in server side with e.g. AngularJS or Node.js in client side, you may speak about MVVM.

MVC with Java EE 6/7 JPA, JTA, EJB3, CDI

I like REST, JPA, JTA, EJB3, CDI & Co. And I like MVC web frameworks, but interesting ones like Play! are not Java EE.
So, just for fun, would it make sense at all to think about something like:
A servlet that accepts REST style URLs and dispatches to managed controllers that can inject EJBs and so on through CDI
The controllers forward/redirect to simple views that act as templates and can use responsive frameworks like Bootstrap
Or does Java EE imply JSF and really nothing else?
I had a look into this topic, wrote a simple JSF webapp and found some interesting resources.
This answer to a related stackoverflow question nicely explains how MVC maps to JSF: Understanding JSF as a MVC framework
Regarding REST style URLs, prettyfaces looks promising.
JSF has nice templating similar to Apache Tiles, and pages can be very simple using plain HTML and CSS with EL.
So, maybe no need to think about/look for something else than JSF and just use it?

GWT MVP and JSF at the same time?

If I do a GWT application with a MVP. Can you confirm that I will not have to use JSF? I have understood that JSF is just for MVC application?
MVC and MVP are patterns so they are not aware of any technology such as GWT or JSF. MVP is a variation of MVC.
GWT and JSF are technologies used for browser-based client applications. They have completely separate origins and implementations. The only thing that may relate them is that both aim to offer AJAX-rich browser JavaScript code at the end.
You won't need JSF if you do GWT apps. You may encapsulate GWT application into JSF if you have large JSF application and you want to take advantage of GWT.
GWT is completly seperate from JSF. Thought you could build a site that uses JSF for some parts and GWT for others.

JSF Adoption and Popularity

Just a general question, open for discussion...
I'm very much liking JSF so far, I'm new to it, but I prefer it to Struts. From a professionals standpoint, do you see a strong future for JSF ? Is it worth an investment as a young programmer to learn JSF 2.0 over Struts or another similar framework ? Should I stick to regular JSP ? Is Ajax really simpler through JQuery than JSF ?
I like new technologies and I like what I see so far from JSF but I want to be practical as well, and a lot Google searches turn up some bluntly critical comments about JSF 2.0.
Thoughts ?
Comparing JSF with Struts is like comparing apples with oranges. Struts is a request/action based MVC framework while JSF is a component based MVC framework. Struts is also aged. In the IT you're supposed to keep moving. Generally, a component based MVC framework is seen as a further evolution of a request/action based MVC framework.
JSF is currently already used very widely. It has indeed received a lot of critism before. You can read about most of them in the question What are the main disadvantages of JSF 2.0? The strength of JSF is mainly being a Java EE maintained standard and the availability of relatively a lot of 3rd party component libraries (PrimeFaces, RichFaces, IceFaces, OpenFaces, Tomahawk, etc). With JSF, it's very easy to develop CRUD applications and web forms with nice look'n'feel quickly.
However when it goes into the complex, JSF may cause some unforeseen surprises. Although the JSF specification and reference implementation (Mojarra) is pretty mature since the latest 1.2 builds, you may encounter some very specific behavioral problems which goes against your intuition. Some are just "by design" and can only be understood when you understand in detail how JSF works under the covers which in turn often boils down to the stateless nature of the HTTP protocol. JSF abstracts it in essence "too much" away that you don't see it anymore. Some are just bugs in the 3rd party component libraries used, but that's thus not strictly JSF-implementation-specific. Bug/issue handling is however pretty good in most of the major component libraries -if you report the bugs timely.
As to ajaxical stuff, JSF 2.0 indeed provides very little manual control over manually firing ajaxical requests and controlling the view tree in both server and client side. Simply because it's a component based MVC framework which keeps the tree state at the both sides. You've got to take the both sides into account when taking the ajaxical works in your own hands. If you really need more freedom in ajax/request based actions, then a component based MVC framework is simply the wrong choice. You should pick a request/action based MVC framework instead like Spring MVC, Struts or Stripes, along with a JS library like jQuery. You however have to write lot of HTML/CSS/JS boilerplate yourself instead.

Best JSF framework/library for "conversation state"

What do people think is the best JSF framework or library for a saving state longer than request scope (but w/o using session scope) that is backbutton/new window safe -- i.e. you have a "wizard"/multi-page form.
For example, MyFaces has the 'SaveState' tag that allows you to maintain state across pages by saving state in the view's component tree. Any comments on SaveState (pros/cons) or suggestions for any better framework or library for this capability?
The t:saveState works perfectly. It's only a bit 'low level' and not tied to a particular bean. There are two other libraries/frameworks which comes to mind which provides control over conversation scope at higher level (e.g. bean-specific tags/annotations):
Apache MyFaces Orchestra (uses tags)
JBoss Seam (uses annotations)
Update: JSF2.0 has added a new scope which achieves a conversation-like state, the #ViewScope. Very useful if you can reuse the same view for subsequent actions.
i think Spring Web Flow is a good solution. you can define your flow as XML and it can integrate with JSF, Struts, Spring MVC, ZK,...
http://www.springsource.org/webflow

Resources