Reputation: 5542
I want to clearly understand the proper way of developing a JSF application.
In our project, the model and controller is the same class, represented by CDI bean. I'm sort of confused whether it's a good practice. As far as I understand MVC pattern, the controller should handle user actions (such as submitting form) and the model should contain business logic and data. Or is it OK, that they are in the same class?
Also, should every page have its own separate Controller/Model (i.e is it considered a good practice)?
Upvotes: 4
Views: 3077
Reputation: 15308
JSF controllers are just UI handlers, they shouldn't carry any business logic. Usually there are even more layers (I include here only layers that relate to logic):
Upvotes: 4
Reputation: 597124
It is generally a better idea to have two layers - one with JSF managed beans (might be managed by CDI) and another one with beans that are agnostic of the web framework that is using them.
As for the "controller" - the FacesServlet
can be viewed as the "front controller" for the entire application.
Upvotes: 6