托管 bean 和支持 bean 之间的区别 [英] Difference between managed bean and backing bean

查看:28
本文介绍了托管 bean 和支持 bean 之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在几个论坛中遇到了术语托管 bean"和支持 bean".很多人认为两者是一样的.但是,似乎有细微的差别.任何人都可以帮助我理解这两个术语之间的确切区别吗?

I came across the terms "managed bean" and "backing bean" in several forums. Many people think both are the same. But, there seems to be a slight difference. Can any one help me to understand the exact difference between these two terms?

推荐答案

改变我的初始答案 - 两者之间没有有意义的区别.tutorial 说支持 bean 后来被声明为托管 bean.所以,总结一下:

Changing my initial answer - there is no meaningful difference between the two. The tutorial says that backing beans are later declared as managed beans. So, to summarize:

  • 支持 bean 是脱离上下文的类
  • 只要声明托管 bean 与 JSF 托管 bean 设施一起使用,托管 bean 就是支持 bean.

我从来没有真正使用过backing bean"这个词,因为我发现它没有用.因此,您最好只使用托管 bean".请注意,在 JSF 2.0(和 CDI)中,您有 @ManagedBean - 所以您的 bean 是一个托管 bean.

I've never actually used the term "backing bean", because I found no use to it. So you might be better off using only "managed bean". Note that in JSF 2.0 (and in CDI) you have @ManagedBean- so your bean is a managed bean.

BalusC 建议backing bean"是定义,managed bean"是实例.虽然这可能是 JSF 创建者的最初想法,但我认为不值得支持它.例如,CDI 和 spring 对于bean 定义"和bean 实例"没有不同的术语.

BalusC suggested that "backing bean" is the definition, and "managed bean" is the instance. While this might have been the original idea of JSF creators, I don't think it is worth supporting it. CDI and spring for example don't have different term for "bean definition" and "bean instance".

JSF 2.0 规范只几次提到术语支持 bean",没有任何定义.除此之外,它还提到了backing bean class",这可能意味着backing bean"!=backing bean class",这带来了进一步的混乱.

The JSF 2.0 specification mentions the term "backing bean" only a few times, with no definition whatsoever. In addition to that it mentions "backing bean class", which might mean that "backing bean" != "backing bean class", which brings further confusion.

所以总结一下 - 对我来说两者都是可以互换的,我会坚持只使用托管 bean"

So to conclude - for me both are interchangeable, and I'd stick to only using "managed bean"

这篇关于托管 bean 和支持 bean 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆