Java – understanding managed beans / backing beans

See the English answer > difference between managed bean and backing bean11

I have some trouble, understand correctly What is managed beans? Is it just an object that keeps the component state? Can they have other ways? Where is EJB suitable? Do managed beans call methods on EJBs?

Solution

JSF managed beans are like any other Java Bean, except that they are managed by JSF In other words, it is a bean that JSF creates and destroys as needed

Hortsman core JSF 2 Book status

The JSF implementation does the following:

>Create and discard beans as needed (so called "manage beans") > read bean properties when displaying web pages > set bean properties when publishing forms

Yes, they can have as many methods as you may want Ideally, though, you'd like to keep your managed beans as lean as possible For example, it may have a search method, but you should not actually search in this method, but the only purpose of this search method should be to delegate the task to the business layer (it may or may not be EJB based) I didn't make a big promotion in other words

EJB is your business layer. They have big biceps and do a lot of work Due to the introduction of EJB3 JPA, it is also a part of EJB JPA is the persistence layer All EJBs except JPA run inside the EJB container All Java EE complaint servers provide these services

In a typical 3-tier architecture (most of these days are more than 3, but the 3-tier is easier to explain) JSF is your web tier, EJB is your business tier and JPA, and it is also a part of the EJB specification, but it does not need the EJB container to be your ORM or persistence tier Don't worry about too many word containers, you'll get used to it soon, and you'll worry about it rarely If you are using a Java EE server, it is all set for you

Yes, as mentioned above All this is heavy However, JSF does not have to use EJB You can use any other framework, such as spring, or even write simple POJOs, but this is another discussion area

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>