ADF介绍

 架构图

ADF是个端到端的开发框架

MVC架构

丰富的展示层技术,有传统的Swing,Office,也有web的展示层技术。

Controller: 主要做画面跳转

Model: JSR-227规范,做数据绑定,将展示层与Business Service(Components)层绑定。

Business Services: 也成为Business Components。与存储交互,主要使用Entity Object, View Object实现。

名词解释:

Facelets:  An open source Web template system under the Apache license and the default view handler technology (aka view declaration language) for JavaServer Faces (JSF). 

RichFace: 使用Ajax技术使得JSF可以异步操作

Model层两个概念

Data controls abstract the implementation technology of a business service by using standard metadata interfaces to describe the service’s operations and data collections, including information about the properties, methods, and types involved.

Data controls 是对business service的抽象,与business service实现的技术无关。

Data Bindings abstract the details of accessing data from data collections in a data control and of invoking its operations. Data Binding是UI访问Data control里的数据(集合)的抽象。有三种Data binding:

Iterator bindings:与一个列表绑定

Value bindings:与一个输出框绑定

Action bindings: 如响应按钮点击事件

数据绑定保存在page definition file,它的命名规约是<pageName>PageDef.xml,位于ViewController/Application Sources/view.pageDefs。ADF会解析该文件,将其保存在一个request-scoped map -- binding container,该map通过EL表达式 ${bindings}访问。每个页面有一个page definition file。

Model层与application model(Business service)的交互

这里application model指business service(component)。在一个request发起时,data control从application model pool里取得一个application model intance,request结束时,释放回application model pool。UI层某个按钮的点击事件通过data control与application model里某个函数相关联。

DataBindings.cpx

<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns="http://xmlns.oracle.com/adfm/application" version="12.1.2.66.68" id="DataBindings"
             SeparateXMLFiles="false" Package="view" ClientType="Generic">
  <definitionFactories>
    <factory nameSpace="http://xmlns.oracle.com/adfm/dvt"
             className="oracle.adfinternal.view.faces.dvt.model.binding.FacesBindingFactory"/>
  </definitionFactories>
  <pageMap>
    <page path="/products.jsf" usageId="view_productsPageDef"/>
  </pageMap>
  <pageDefinitionUsages>
    <page id="view_productsPageDef" path="view.pageDefs.productsPageDef"/>
  </pageDefinitionUsages>
  <dataControlUsages>
    <dc id="StoreProducts" path="model.StoreProducts"/>
  </dataControlUsages>
</Application>

该文件默认位于ViewController/Application Sources/view目录。两种内容:某个UI页面与它的page definition文件的映射;data control注册。这个文件定义一个binding context。在运行时,ADF读DataBindings.cpx文件初始化binding context,binding context是application级别,所有data control和page definition的map,通过EL expression - #{data}访问。没有在DataBindings.cpx文件注册的data control不会被实例化。Binding Context内包含的是这些对象的引用。

DataControls.dcx:定义application内的Data Control。

Facelet文件:
<af:inputText value="#{bindings.pid.inputValue}" label="#{bindings.pid.hints.label}"
              required="#{bindings.pid.hints.mandatory}" columns="#{bindings.pid.hints.displayWidth}"
              maximumLength="#{bindings.pid.hints.precision}" shortDesc="#{bindings.pid.hints.tooltip}"
              id="it1">
	<f:validator binding="#{bindings.pid.validator}"/>
    <af:convertNumber groupingUsed="false" pattern="#{bindings.pid.format}"/>
</af:inputText>

Page Definition File:
<attributevalues iterbinding="productsIterator" id="pid">
  <attrnames>
	<item value="id">
  </item></attrnames>
</attributevalues>

<accessoriterator masterbinding="StoreProductsIterator" binds="products" rangesize="25" datacontrol="StoreProducts" beanclass="model.Product" id="productsIterator">

DataControls.dsx
<adapterdatacontrol id="StoreProducts" factoryclass="oracle.adf.model.adapter.bean.BeanDCFactoryImpl" impldef="oracle.adf.model.adapter.bean.BeanDCDefinition" supportstransactions="true" supportssortcollection="true" supportsresetstate="false" supportsrangesize="false" supportsfindmode="false" supportsupdates="true" definition="model.Products" beanclass="model.Products" xmlns="http://xmlns.oracle.com/adfm/datacontrol"/>              

	<f:validator binding="#{bindings.pid.validator}"/>
    <af:convertNumber groupingUsed="false" pattern="#{bindings.pid.format}"/>
</af:inputText>

Page Definition File:
<attributevalues iterbinding="productsIterator" id="pid">
  <attrnames>
	<item value="id">
  </item></attrnames>
</attributevalues>

<accessoriterator masterbinding="StoreProductsIterator" binds="products" rangesize="25" datacontrol="StoreProducts" beanclass="model.Product" id="productsIterator">

DataControls.dsx
<adapterdatacontrol id="StoreProducts" factoryclass="oracle.adf.model.adapter.bean.BeanDCFactoryImpl" impldef="oracle.adf.model.adapter.bean.BeanDCDefinition" supportstransactions="true" supportssortcollection="true" supportsresetstate="false" supportsrangesize="false" supportsfindmode="false" supportsupdates="true" definition="model.Products" beanclass="model.Products" xmlns="http://xmlns.oracle.com/adfm/datacontrol"/>              

UI组件的UI hints的属性:

Display Hint: Determines whether the attribute will be displayed or not.
Label: The text used in prompts or table headers that precede the value of a data item.
Tooltip: The text used in tooltips or flyover text. In web applications, it appears as the value of the HTML ALT attribute.
Format Type: Defines the formatter to use when the data item is displayed. Formatters are basically a collection of format masks that you can define in the <JDeveloper_Install>/jdeveloper/systemn.n.n.../o.BC4J/formatinfo.xml file.
Format: The particular format mask used by the selected formatter.
Control Type: The control type used to display the data item in the client UI: Edit makes the control editable, Date displays a calendar picker, and Default is interpreted by the client to select the most appropriate control.
Display Width: Defines the character width of the control that displays the data item.
Display Height: Defines the number of character rows of the control that displays the data item.
Form Type: Determines whether the attribute will be displayed in Detail or Summary mode. Detail mode produces a long form, Summary mode a short one. This property is supported for ADF Swing applications only; it is not available for Business Components web applications.
Field Order: Defines the numeric order in which you want the attribute to render within a category
Category: The identifier to be used by the dynamic rendering user interface to group attributes for display. The user interface will render the attribute with other attributes of the same category. You can use the category hint to aid the user interface to separate a large list of view object attributes into smaller groups related by categories. This control hint will be utilized by any dynamic rendering user interface that displays the attribute.
Auto Submit: Triggers a partial submit on value changes in the user interface when set to true (enabled).

当用户修改了UI Hints时,JDev自动往Model/Application Sources/model添加一个文件ModelBundle.properties。用户可以使用该文件支持多国语言显示。

Iterator的RangeSize

<executables>
<iterator Binds="root" RangeSize="25" DataControl="SupplierFacadeLocal" id="SupplierFacadeLocalIterator"/>
<accessorIterator MasterBinding="SupplierFacadeLocalIterator" Binds="addressesFindAll" RangeSize="25"
  DataControl="SupplierFacadeLocal" BeanClass="oracle.fodemo.supplier.model.Addresses" id="addressesFindAllIterator"/>
</executables>

RangeSize相当于SQL*Plus的arraysize.
 

猜你喜欢

转载自blog.csdn.net/chncaesar/article/details/19039045