Let us take a basic example. In a servlet app I would have those classes:
- app.domain.User: domain or model POJO, would contain fields and getters/setters
- app.service.UserService: would contain methods that operate on User instances, such as
Register(User)
. Would call the DAO. - app.dao.UserDao: would be called by service to actually, say, insert a User in the DB.
- app.servlets.RegisterController: a servlet intercepting requests to www.app/registration and calling the methods in app.service.UserService. It would then redirect to
WEB-INF\JSPs\registration.jsp
which would take care of the view.
All this made perfect sense to me and clearly separated the concerns.
I have tried since to wrap my head around the JSF/Facelets way of thinking. I have went through many excellent resources here in SO and otherplaces but there is not any place that addresses this simple question - namely how does the dao/service/controller/view pattern translate into JSF.
To continue my example - I have set up a JSF project in eclipse, have translated my DB schema to "entities"
and now I am left wondering - what kind of package, with what king of classes should I create to handle user Registration ? I understand I have to create xhtml pages for the view but where is the controller ?
Please do not point me to tutorials - I am aware of many, amongst which the @BalusC one - my problem is not to make this work but to understand the pattern. I have seen "session" packages containing "managed beans", "abstract facade" patterns etc etc but nothing that makes as clear sense as the good old servlets pattern.
So - among the "entities" created by the DB there is a User.java class that looks like the model to me. The view will be an xhtml. The controller ?
NB: this is not asking as so many duplicates here the differences between those technologies - I am asking about a clear translation of the very clear and intuitive controller/dao/service pattern to the JSF framework - or a clear statement that there is not such a translation.
See also:
- The NetBeans E-commerce Tutorial - bit outdated, actually uses JSP (!)
- An Eclipse / GlassFish / Java EE 6 Tutorial actually uses Servlets (!) but at least is eclipse based
- JSF 2.0 tutorial with Eclipse and Glassfish the BalusC one I referred to
- A school project featuring the servlet pattern and another bigger one with CDI
- Understanding JSF as a MVC framework