I\'d starting to learn JSF, but first I\'d like to understand the big picture of it as an MVC framework.
There are several answers with many upvotes explaining what
I'm mostly concerned about Managed beans here. Are they M or C?
People consider them M when they look like this:
@ManagedBean
public class Bean {
private String username; // +getter+setter
private String password; // +getter+setter
@Resource
private DataSource dataSource;
public void login() {
try (
Connection connection = dataSource.getConnection();
PreparedStatement statement = connection.prepareStatement("SELECT * FROM User WHERE username = ? AND password = MD5(?)");
) {
statement.setString(1, username);
statement.setString(2, password);
try (ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) {
// Login.
}
}
}
}
// ...
}
But people consider them C when they look like this:
@ManagedBean
public class Bean {
private User user // +getter
@EJB
private UserService userService;
public void login() {
if (userService.find(user) != null) {
// Login.
}
}
// ...
}
This is also mentioned in the very same MVC answer you found:
Note that some starters and even some —very basic— tutorials mingle/copy/flatten the entity's properties in the managed bean, which would effectively make the controller a model. Needless to say that this is poor design (i.e. not a clean MVC design).