What is difference between JavaBean and ManagedBean
Asked Answered
J

1

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?

Jacie answered 7/6, 2013 at 7:48 Comment(1)
D
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.

Donyadoodad answered 7/6, 2013 at 8:5 Comment(4)
I am learning JSP application,, And I dont know where to put the business logic. Where is the comtroller part?Jacie
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 #746547Donyadoodad
another link : #7223555Donyadoodad
Not really, I didn't use this since ages, sryDonyadoodad

© 2022 - 2024 — McMap. All rights reserved.