71

I haved used Struts framework in all my past applications and for the new application,my client has requested to use either Spring MVC or JSF? I am not familiar with these two frameworks but our timelines are strict. So, I am not sure which framework I will choose to build the application.

Can anyone please suggest me which framework will be easy to learn in quick time?

Thanks

tereško
  • 58,060
  • 25
  • 98
  • 150
Yatish
  • 855
  • 2
  • 8
  • 8
  • Will you be using the rest of the Spring stack a long with it? – Drew Feb 12 '10 at 15:56
  • Thanks experts for the answers. I am also thinking now to go for Spring MVC rather than JSF. Our Web designer has provided us the static htmls and I think it would be tough to convert the static htmls to JSF pages(as it uses UI component). I hope Spring MVC also provides tags similar to struts logic:iterate.. – Yatish Feb 12 '10 at 07:36
  • 1
    Yes, if you have HTML pages from a web designer, it's much easier to use them for Spring MVC views than convert them to JSF components. As for the tag - I think I've usually just used the JSTL c:forEach tag for that for that. The Spring taglibs are pretty minimal - http://static.springsource.org/spring/docs/2.0.x/reference/spring.tld.html - but JSTL taglibs are used also - because model objects are just POJOs/JavaBeans JSTL works fine. – Nate Feb 12 '10 at 13:19
  • Agreed, in this case. I personally like JSF better as it better fits my coding style but in this case, Spring MVC would probably be better. – Drew Feb 12 '10 at 15:56
  • So tell me, Yatish, now after a year and a half, what do you think about Spring MVC? (though I'm afraid it's a rhetorical question) – spauny Nov 23 '11 at 08:13
  • 5
    Note: I didn't protect the question because the question is valid, in contrary, I find that this question should be deleted. I protected it because I want to prevent that new users continue spamming this question with irrelevant subjectiveness and hereby continue to abuse Stack Overflow as dicussion forum platform. I already downvoted the question and voted for close because it doesn't belong here at all. However, the close vote has expired and apparently nobody else could be bothered about this question being at the wrong place. – BalusC Aug 07 '13 at 12:04

5 Answers5

52

Of course, it's going to be different for everyone, but I'd suggest Spring MVC, as it's a request-based framework like Struts. Of course, you'll want to learn about core Spring stuff like Inversion of Control / Dependency Injection (but I'd consider that a plus...) and whatever you're going to use for database access (just JDBC? Hibernate? iBatis? etc.).

JSF is component-based, which is a bit different paradigm from request-based frameworks. If you do plan to go the JSF route, I'd suggest looking at Seam from JBoss. It's more of a front-to-back framework that uses JSF as the web/presentation end and EJB as the backend. And pretty much all the people who've used it claim it makes JSF and EJB more usable than they are by themselves.

Good luck on whichever technology you choose, though. (Sounds like you'll need it - strict timelines and a client that's prescribing web frameworks?)

Nate
  • 16,748
  • 5
  • 45
  • 59
  • 4
    Just a FYI: JSF 2 has some nice features that Seam came up with (conversation scope, CDI), and uses annotations heavily instead of XML. It seems much nicer to work with than JSF 1.2 and earlier versions. – Jon Onstott Nov 24 '10 at 17:56
26

I'd suggest SpringMVC, because of the timeframe:

  • you need something with less steep learning curve. SpringMVC is more like Struts than JSF
  • in order to use the power of JSF you need to get familiar with many "tricks", while SpringMVC is more or less straightforward
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • This summarise everything :) - in order to use the power of JSF you need to get familiar with many "tricks" – Gautam Jan 18 '19 at 06:40
13

I'd suggest JSF + Primefaces component library. I am using this combination to build most of our projects. As I remember, I spent one week to learn the technology and finished my first project in one month. The development time at least 30% faster than Struts.

SpringMVC is not a bad technology and it's quite popular.

Really depends on which one your like the most.

Ted
  • 165
  • 1
  • 2
  • 5
    My team struggled with this same decision for a few days, before realizing how powerful Primefaces (and Primefaces Mobile) really was. Mind you, Primefaces is not perfect; we've had to write a few Javascript and CSS hacks inside our .xhtml from time to time to accomodate for browser rendering differences. Primefaces does, however, keep it simple and powerful - RAD at it's finest. – Fuzzy Analysis Oct 10 '14 at 22:54
  • 1
    I would voice dissent. Primefaces is a powerful library but the documentation for it is abysmal. I've spent weeks hacking things into existence and it's been painful. I'd recommend Spring because there are more resources available and i'd definitely recommend doing it with intellij over eclipse and doing it with a well supported application container like tomcat. – MarkyMarksFunkyBunch Jun 04 '18 at 15:27
6

JSF is just the view layer of the MVC and wil need to be used with other technologies like Spring/Hibernate or EJB for a full MVC.

I have been using the Spring MVC for about 1 months now, whilst it's probably not the latyest version of SpringMVC I've found it a little annoying that we have so much XML to deal with. All the managed beans and DAO has XML config to it. Also everything seems to have to go thorugh a method called onSubmit().

JSF with something like EJB is far simplier in my opinion... Everything can be done using Annotations so simply use @ManagedBean=theBean in your backing bean and in your JSF put {thebean.param} and you have access to the backing bean's data. Also you can use the Session beans of your EJB as the backing beans for JSF then have direct acces to the DAO (Model layer) Entity bean. Again simply by using the @Entity annotation and the EntityManager class

Spring MVC is a web framework inside the Spring framework. It does provide features as those in JSF 2.0: ajax-support validation dependency-injection etc Yet, you can use Spring (not Spring MVC) together with JSF 2.0, with spring providing the dependency-injection, aop, transaction management mechanisms, and JSF providing the web layer.

Dhrumil Shah
  • 736
  • 6
  • 15
  • 8
    "JSF with something like EJB is far simplier ..." is not true. With SpringMVC, since 2.5, applications have the option to be annotation driven and everything can be done with annotations with minimal XML configuration. – Sully Apr 13 '14 at 09:31
  • 3
    "I have been using the Spring MVC for about 1 months now" If you're just getting started with Spring how do you figure you're skilled enough to weigh Spring against JSF? – Edward J Beckett Sep 09 '14 at 17:02
  • (sic) "I've found it a little annoying that we have so much XML to deal with" is defimitely no longer a valid argument. You can declare and hook all your components in Spring with annotations (use v3 onward). The duality is quite convenient as you can mix "centralized" XML-based config meta-data with annotations distributed in code, using the former to -for instance- take advantage from controlling dev/test/qual/prod profiles at one place, and the later to manage all bindings that do not depend from a runtime environment but derive from you intrisical component architecture. – Bernard Hauzeur Sep 03 '15 at 14:20
5

Of course, you'll want to learn about core Spring stuff like Inversion of Control / Dependency Injection (but I'd consider that a plus...)

JSF is indeed based on IoC, and much simpler than the Spring learning curve.

J Slick
  • 929
  • 11
  • 17
  • Mmm could you provide an example where JSF uses IoC? – Aritz Jun 27 '14 at 12:30
  • Yeah, I suppose it's IoC. Was just a question, as you didn't clarify it in the answer above ;-) BTW, despite I'm a JSF supporter, I must admit the learning curve can vary depending on your previous experience and knowledge, can't it? – Aritz Jun 27 '14 at 15:32
  • 2
    Example: in JSF, use annotations in a bean to inject other beans: Suppose bean1 is an instance of SomeBean1. In another bean, use @ManagedProperty(value="#{bean1}"). Place that before the declaration of the property which will accept injected bean1: private transient SomeBean1 refToBean1; Alternatively, can also use this in faces-config for the target bean: refTobean1#{bean1}. – J Slick Jun 27 '14 at 20:57