10

I am reading What components are MVC in JSF MVC framework?

In the big architectural picture, your own JSF code is the V:

M - Business domain/Service layer (e.g. EJB/JPA/DAO)
V - Your JSF code
C - FacesServlet

In the developer picture, the architectural V is in turn dividable as below:

M - Entity
V - Facelets/JSP page
C - Managed bean

On the upper case, the JavaBean is a model.

But on the lower case, the Managed bean becomes a controller?

They are not the same thing? What are the difference?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jeff Lee
  • 783
  • 9
  • 17

1 Answers1

13

Short answer : 'Managed Bean' is a legacy short name for JSF managed bean. It's a Java Bean managed by JSF.

Long one :

A bean is typically a POJO (plain old java object) managed by a container.

Managed means here that the creation / destruction, the number of instances, their scope and the invocation of some specific method are handled by the container.

Containers are generally provided by the underlying server. In Java EE you have different container (CDI, EJB, Web, etc...)

JSF Managed Bean are bean managed by JSF container, EJB are managed by EJB Container, Servlet / filters by the servlet container, JPA entities by the EntityManager, etc.

For example, on a tomcat server, you have only web (servlet) container and not EJB one. If you use JSF (you must provide associated dependency) you will have managed beans as well.

Gab
  • 7,869
  • 4
  • 37
  • 68
  • I am learning JSP application,, And I dont know where to put the business logic. Where is the comtroller part? – Jeff Lee Jun 07 '13 at 08:08
  • It depends. You generally have a front controller to handle and dispatch request to underlying business controllers that manage one or more view and interact with persistence layer. If you use JSP with JSF See http://stackoverflow.com/questions/746047/jsf-backing-bean-structure-best-practices – Gab Jun 07 '13 at 08:12
  • 1
    another link : http://stackoverflow.com/questions/7223055/distinction-between-different-types-of-managed-beans/7223910#7223910 – Gab Jun 07 '13 at 08:15
  • Not really, I didn't use this since ages, sry – Gab Jun 07 '13 at 08:34