-1

I would like some clarification on some things.

I have developed a web application in the Eclipse IDE using JSF and facelets (xhtml web pages). Now, my manager told me to re-create this application but as a RESTful web application using Spring.

I did some research on Spring MVC and its DI/IoC features and have a few questions:

I see that Spring offers DI/IoC, does JSF not offer that? Can you create RESTful web apps in JSF? Since JSF uses beans just like Spring, what advantage is there to use Spring over JSF? Are the facelets just the view part of the Spring framework? Can I use Spring IoC/DI with facelets?

I am starting to think he just wants me to keep the project as is but add the IoC/DI of Spring.

As you can see, I am quite confused on this subject and would like some clarification.

Freak
  • 6,786
  • 5
  • 36
  • 54
Viratan
  • 503
  • 3
  • 9
  • 19
  • You're comparing "JSF" to "Spring" which is in first place totally wrong and apparently the root source of all your confusion. You should compare "Java EE" to "Spring". Then, JSF is like Spring MVC, and CDI/EJB is like Spring IoC/DI, and JAX-RS is like Spring Web, etc. – BalusC Jul 05 '15 at 12:19
  • @BalusC, I read your answers and Spring MVC is action-driven while JSF MVC is component-driven. I see you said that you can use Facelets in Spring MVC, and Spring IoC/DI in JSF MVC, but you cannot use Spring MVC and JSF MVC together as that would not make sense. Now, can you create a RESTful web application in JSF? – Viratan Jul 05 '15 at 20:55

1 Answers1

0

I can understand your confusion. Once I did a project in which I used JSF as front end and Spring MVC as backend.
for you the answer is Yes , You can do inversion of control using JSF by using JSF Beans (for instance managed beans) but you need to keep in mind couple of things.
1: You need to register beans both for JSF and Spring.
2: Its recommneded that you should set same type of scope for this bean in JSF and Spring.
for example: if you are setting request scope for a specific bean in JSF then you should also set Request scope for the same bean in Spring. Only view scope will not be available in Spring but you can write custom view scope which is not big deal
Answer for the part of question Are the facelets just the view part of the Spring framework?
No, you can't say it is part of spring, facelets are handled by JSF but yes , they mostly used as a view part. So when you have a plan to make a application with JSF and Spring then I will interpret it as you are using JSF for front end and Spring for backend.
Restful services using JSF:
Yes, you can make restful service using JSF. here it is very good blog regarding thisRestful web Services in JSF
You can also create restful web service in Spring Rest Web Services in Spring

Freak
  • 6,786
  • 5
  • 36
  • 54
  • I see, but I don't see the need to have the same beans implemented using two different frameworks. Maybe I need to clarify with my manager on what he really wants. – Viratan Jul 04 '15 at 23:58
  • Please look at the edited answer and if you find something new and helpful , then I will look for rewards of up vote and acceptance of answer by you :) :P – Freak Jul 05 '15 at 00:00
  • ah ok I see now, thanks for the answer. – Viratan Jul 05 '15 at 00:10
  • "Spring MVC as backend", sorry this is pure nonsense. You're confusing Spring DI/IoC with MVC. – BalusC Jul 05 '15 at 12:17
  • The only way of using JSF and Spring MVC altogether is having different url mappings for them. This way you can take advantage of having some Spring beans as services and accessing them from JSF and from Spring MVC as well (for RESTful services as you said). However, mixing both framework lifecycles in the same HTTP request can only result in a disaster x-( – Aritz Jul 10 '15 at 12:43