This question already has answers here:
Using JSF as view technology of Spring MVC
(3 answers)
Closed 7 years ago.
Can I use jsf component libraries(primefaces) with spring mvc .I have problem with client side development so i want a simple way of creating user interfaces .And I dont like jsf life cycle .I need a way of using component libraries.
JSF and Spring MVC have completely different ideologies. The one is a component based MVC framework and the other is a request based MVC framework. Mixing this makes no sense. You normally choose the one or the other. A component based MVC framework has the advantage that it minimizes the HTML/CSS/JS boilerplate code and the server side request processing, but this brings the disadvantage back that you don't have fine grained control over the generated HTML/CSS/JS and the server side request processing. For that you'd need a request based MVC framework. But this has in turn the disadvantage that you need to write all that HTML/CSS/JS boilerplate and server side request processing yourself.
If you want to stick to Spring MVC and want a rich UI, I suggest to look at a JavaScript based UI library, such as jQuery UI.
See also:
What is the need of JSF, when UI can be achieved from CSS, HTML, JavaScript, jQuery?
Related
This question already has answers here:
What is the need of JSF, when UI can be achieved with JavaScript libraries such as jQuery and AngularJS
(8 answers)
Closed 2 years ago.
Is JSF (javaServer faces) same technology as .net WebForm? why is it still in use? .Net is not supporting WebForm anymore
ASP.NET and JSF are similar.
JSF is still in use because it's part of Java Enterprise Edition. For example PrimeFaces is one of the largest Component collection and has lot of active users.
Microsoft moved to MVC and later to .NET core.
On the Java side you have Spring MVC as the equivalent.
Why is JSF still used: Because a component based model may have some advantages for enterprise business applications.
As always it depends and you have to choose the technology fits the requirements.
Btw. most frontends today are created using a SPA (Single Page Application) framework like Angular, React or Vue.
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.
There is an existing web application created in Struts. There is a need to totally redo the UI. What is the best way to improve the UI? Will intrducing JSF components like PrimeFaces into the existing Struts code be a good idea? Or what are the options available?
It is hard to join Struts with JSF, since those are two different frameworks trying to do the same thing. So, in practice, you'll end-up rewriting your application. JSF pages and JSP (which are used by Struts) have different livecycle, JSF Beans are working in a different way then Struts Actions.
The point is to make use of that what you already have and make your JSP look better. I would choose good JavaScript UI library and rewrite JSP pages using it. ExtJS is a very good, if you want complete solution. If you want to create custom solution looke at jQuery, Backbone and Mustache templating engine.
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.
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.