Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between JavaBean and ManagedBean

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?

like image 956
Jeff Lee Avatar asked Jun 07 '13 07:06

Jeff Lee


People also ask

What is a Managedbean?

Managed beans are container-managed objects with minimal supported services, such as resource injection, life cycle callbacks and interceptors, and have the following characteristics: A managed bean does not have its own component-scoped java:comp namespace.

What is JavaBean used for?

JavaBeans is a portable, platform-independent model written in Java Programming Language. Its components are referred to as beans. In simple terms, JavaBeans are classes which encapsulate several objects into a single object. It helps in accessing these object from multiple places.

What is JavaBean standard?

The JavaBeans standard provides a framework for creating objects to be used by GUI tools, including Java development environments. But in more common usage, a bean is a serializable class that follows the JavaBeans naming conventions for its properties. These naming standards make it easy to use Java introspection.

Why is it called JavaBean?

actually when they were developing java , the developers consumed so much of coffee so they made it as their symbol. and then so as the beans are small parts of the coding they named it as beans corresponding to small coffee beans.


1 Answers

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.

like image 79
Gab Avatar answered Nov 04 '22 01:11

Gab