ADF: managed bean 和 backing bean的区别

1,Manged bean 和 backing bean的区别(what's the difference between managed bean and backing bean),可以参考下面链接:

1)http://prasanna-adf.blogspot.com/2008/02/managed-bean.html

其中的一段话是:

Backing bean and Managed bean are not different they are the same. Managed bean is about how the bean is created and initialized. Backing bean is about the role a particular managed bean plays.

In other way, Managed bean is a JavaBean registered in the adfc-config.xml file. These beans have properties that are bound to the values of UIComponents.

Backing bean is a special type of managed-bean consisting of properties that are UIComponents. Instead of the bean properties being bound to the UIComponent values, they are instead bound to the UIComponents themselves.

2)http://www.indiastudychannel.com/experts/267-What-difference-between-managed-bean-backing-bean.aspx

 

2,在ADF中如何创建Managed(Backing) bean

下面介绍了两种方法:

http://udayarocks.wordpress.com/2011/06/08/how-to-create-a-managed-backing-bean-for-any-jspx-page/

 

3,上面2中介绍的两种方法是在Fusion web application中的;也可以在faces-config.xml中定义Managed(Backing) bean,这也被Oracle称作standard JSF application。

Managed(Backing) bean被定义在哪个文件里,ADF会有不同的处理:

Managed Bean PlacementEffect
adfc-config.xml(无边界Task Flow)
  1. Managed bean can be of any scope. However, any backing 
    beans for page fragments or declarative components should 
    use BackingBean scope.
  2. When executing within an unbounded task flow, 
    faces-config.xml will be checked for managed bean 
    definitions before the adfc-config.xml file.
  3. Lookup precedence is enforced per scope. Request-scoped 
    managed beans take precedence over session-scoped 
    managed beans. Therefore, a request-scoped managed bean 
    named foo in the adfc-config.xml file will take 
    precedence over a session-scoped managed bean named 
    foo in the current task flow definition file.
  4. Already instantiated beans take precedence over new 
    instances being instantiated. Therefore, an existing 
    session-scoped managed bean named foo will always take 
    precedence over a request-scoped bean named foo defined 
    in the current task flow definition file.
Task flow definition file(有边界Task Flow)
  1. Managed bean can be of any scope. However, managed 
    beans of request scope, of pageFlow scope, of view 
    scope, or with the scope set to none that are to be accessed 
    within the task flow definition must be defined within the 
    task flow definition file. Any backing beans for page 
    fragments in a task flow should use BackingBean scope.
    Managed bean definitions within task flow definition files 
    will be visible only to activities executing within the same 
    task flow.
  2. When executing within a bounded task flow, 
    faces-config.xml will be checked for managed bean 
    definitions before the currently executing task flow 
    definition. If no match is found in either location, 
    adfc-config.xml and other bootstrap configuration files
    will be consulted. However, this lookup in other 
    adfc-config.xml and bootstrap configuration files will 
    only occur for session- or application-scoped managed 
    beans.
  3. Lookup precedence is enforced per scope. Request-scoped 
    managed beans take precedence over session-scoped 
    managed beans. Therefore, a request-scoped managed bean
    named foo in the adfc-config.xml file will take 
    precedence over a session-scoped managed bean named 
    foo in the current task flow definition file.
  4. Already instantiated beans take precedence over new 
    instances being instantiated. Therefore, an existing 
    session-scoped managed bean named foo will always take 
    precedence over a request-scoped bean named foo 
    registered in the current task flow definition file.
  5. Customizations are allowed.
faces-config.xml
  1. Managed beans can be of any scope other than pageFlow 
    scope or view scope.
  2. When searching for any managed bean, the 
    faces-config.xml file is always consulted first. Other 
    configuration files will be searched only if a match is not 
    found. Therefore, beans registered in the 
    faces-config.xml file will always win any naming 
    conflict resolution.
  3. No customizations can be made.

 

4,在ADF中使用Manage(Backing) bean的best practice

Use managed beans to store logic that is related to the UI rendering only. 



All application data and processing should be handled by logic in the business layer of the application. Similar to how you store data-related logic in the database using PL/SQL rather than a Java class, the rule of thumb in a Fusion web application is to store business-related logic in the middle tier. This way, you can expose this logic as business service methods, which can then become accessible to the ADF Model layer and be available for data binding.

 

5,不要误认为managed bean从属于任何一个页面,一个managed bean可以为多个页面服务,他的生命周期只与managed bean定义时的scope有关。




更多信息可以参考:

Fusion Developer's Guilde for ADF: Using a Managed Bean in a Fusion Web Application


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值