0

I am learning to build a JavaEE application, and I find that JSF's controller layer very similar to REST service, they all invoke the service layer's methods to reach the same goal. So if I already have a REST service and then want to build the front-end, do I need JSF? Or can I just use HTML/AJAX? To be frankly, the real question I'm now facing is that how to interagte the front-end and back-end together. I'm really confused about it, please help me, thank u so much!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
MarcuX
  • 331
  • 4
  • 16
  • 1
    Probably best to go for a MVC approach, but that does not mean you should use JSF – Scary Wombat May 02 '17 at 06:28
  • 3
    You could use HTML and some client side framework like AngularJS, sure. Or you could access the API through JSF and use it to manage your views too. Which framework to choose depends on various factors. – Aritz May 02 '17 at 06:33

1 Answers1

1

The REST service IS your interaction layer. Whether it talks to a JSF application, an Angular application, a C# application, Cobol, or whatever is completely irrelevant.

Many REST services never talk to a web frontend at all.

jwenting
  • 5,505
  • 2
  • 25
  • 30
  • Hmmm... No it is not... In jsf applications there is totally no need to write a rest service for communication between the client and server. That is build-in the framework. Calling rest **from** the jsf layers is also not 'right', it should be in the service layer. The 'controller' layer should not know of any implementation details of services (being it rest, database, ldap)... – Kukeltje May 02 '17 at 07:06
  • @Kukeltje sure, if the business logic is inside the JSF application. If it isn't, you can use REST to exchange data between the business logic and the JSF frontend, just like you would between the business logic and an Angular frontend, or between a Java backend and an ASP frontend. – jwenting May 02 '17 at 07:18
  • No, regarding separation of concerns, the ui layer should not know of back-end implementation details.'JSF' talks to a service layer which in turn talks to a backend (rest, ldap, db) – Kukeltje May 02 '17 at 07:21
  • 1
    @Kukeltje yes, of course. I wasn't talking about putting REST services inside a JSF application. A REST client possibly. – jwenting May 02 '17 at 08:41