<component>com.adobe.devnet.example.ARTISTSAssembler</component>
<!-- Either "application" or "request" -->
<scope>application</scope>
<!--
Should we look for "getFoo" or "setFoo" when translating an
ActionScript object to a CFC? If not found, the value is set in the
"this" scope. If your CFCs don't have getters and setters,
(they use the this scope) set this to false for better performance.
Optional, Default is true - look for accessor functions.
-->
<use-accessors>true</use-accessors>
<!--
Should we create CFML Structures instead of value objects
when translating an ActionScript object with a remote alias?
Optional, Default is false (use CFCs)
-->
<use-structs>false</use-structs>
<!--
The hostname or IP address of the CF host.
If Data Services is installed as part of CF, you omit this.
If Data Services runs outside of CF, you must define this.
<hostname>localhost</hostname>
-->
<!--
This is the ID of the ColdFusion Data Management service as configured
in the ColdFusion Administrator.
Only needed if you have more than one instance of CF on a machine
and Data Services is not installed as part of CF.
<identity>default</identity>
-->
<!--
Credentials to pass to the assembler CFC for all clients
Generally better to use setRemoteCredentials() API on client
<remote-username></remote-username>
<remote-password></remote-password>
-->
<!-- Define the resolution rules and access level of the CFC being invoked -->
<access>
<!-- allow "public" (and remote) or just "remote" methods to be invoked -->
<method-access-level>remote</method-access-level>
</access>
<!-- Optional controls for forcing property names to lowercase when converting to ActionScript -->
<property-case>
<!-- cfc property names -->
<force-cfc-lowercase>false</force-cfc-lowercase>
<!-- Query column names -->
<force-query-lowercase>false</force-query-lowercase>
<!-- struct keys -->
<force-struct-lowercase>false</force-struct-lowercase>
</property-case>
<metadata>
<identity property="ARTISTID" undefined-value="0"/>
<!--
Optional, If the Assembler fill routine returns a query,
you must define an ActionScript type for the rows.
<query-row-type>com.adobe.icm.serverObjects.dataAccess.ICM_SALES_ORDER</query-row-type>-->
</metadata>
<network>
<!-- Add network elements here -->
</network>
<server>
<!--
The method declarations are ignored for CFC Assemblers,
with the exception of the fill-method settings.
No parameters are defined here, unlike Java.
Any arguments provided via the ActionScript call are passed along to the CFC,
just use optional arguments when defining the CFC.
-->
<fill-method>
<!--
Does the assembler have a "fill-contains" method?
This method is used to determine whether to refresh the fill.
If the specified method returns true the fill is re-executed
after a create or update.
Auto-refresh determines if the fill is always refreshed if not specified.
May only be used when auto-refresh is true.
Optional. Default is false.
-->
<use-fill-contains>false</use-fill-contains>
<!--
Determines whether to refresh the fill on updates or creates.
Optional. Default value is true.
-->
<auto-refresh>true</auto-refresh>
<!--
Determines whether order is important for this filled collection. Allows for
performance optimization when order is not important.
Optional. Default value is true.
-->
<ordered>true</ordered>
</fill-method>
</server> </properties> </destination>
整合
现 在已经配置了ColdFusion和LiveCycle Data Services ES,服务器端ColdFusion CFC文件也已就位,剩下的工作就是向Flex UI添加几行简单的代码。在Flex Builder 3中,打开myProject.mxml文件。将下列代码复制并粘贴到此文件中:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="fillArtistDP()">
<mx:Script>
<![CDATA[
import com.adobe.devnet.example.ARTISTS;
import mx.collections.ArrayCollection;
//This dummy variable forces Flex Builder to include Artists object in build
private var dummy:ARTISTS = new ARTISTS();
//ArrayCollection that will hold the data returned from the artistDataService
[Bindable]
private var artistDP:ArrayCollection = new ArrayCollection();
//Function executed on creationComplete event to call the Fill method on artistDataService
private function fillArtistDP():void
{
artistsDataService.fill(artistDP);
}
]]>
</mx:Script>
<mx:DataService id="artistsDataService" destination="artgallerydataservice"/>
<mx:DataGrid editable="true" dataProvider="{artistDP}" width="100%" height="100%"/>
</mx:Application>
这就是使运行本示例所需的全部代码!
DataService
标 签指向在data-management-config.xml文件中创建的指向ARTISTSAssembler.cfc的 artgallerydataservice目标。DataService标签被设为可编辑,因此用户能够在字段中单击并直接编辑数据。一旦用户进行了编 辑并离开单元格,该修改将提交回artgallerydataservice,然后将修改推送到所有其他连接的客户机。DataGrid从与它绑定的 artistDP数组集合处获得数据。因为应用程序标签指定creationComplete=“fillArtistDP()”,所以应用程序完成装载 后将执行fillArtistsDP方法。此方法只是对DataService调用fill方法并引用由服务生成的数据填充的artistDP数组集合。
现 在您能够在http://localhost:8300/myProject.html浏览web root。如果一切正常,您应该看到一个可编辑数据的表格(见图16)。您可以单击每个单元格并修改其值。当焦点离开单元格时,修改被提交并存储到服务 器。真正酷的是当您打开两个以上的浏览器时,在一个浏览器中修改值,当服务器将您的修改推送到所有其他连接的客户机时,您将立刻在所有其他的浏览器中看到 该修改。

图15.显示Advanced DataGrid的应用程序用户界面。
结束语
虽然本文并没有介绍构建Flex 3和ColdFusion 8应用程序的最佳实践,但是,本文展示了开发人员可以轻松地上手并构建复杂的功能。
从 本示例中,您了解了ColdFusion 8、Flex 3、CFC Wizard插件和LiveCycle Data Services ES提供的生产力优势如何使您能够快速构建拥有健壮数据管理能力的富Internet应用程序。ColdFusion 8拥有其他竞争技术所难以比拟的生产力,是富Internet应用程序的强大后端。Flex 3使您能够以最少量的工作快速构建吸引人的UI并轻松连接到诸如ColdFusion 8和LiveCycle Data Services ES的后端服务。配备了最新Adobe技术的开发人员绝对会拥有非常美妙的体验。
本文由Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License颁发许可。
关于作者
Brian Szoszorek
自2000年来一直开发ColdFusion应用程序。他是一位经过认证的ColdFusion开发人员,并且是New Point Media的 首席技术专家。他为诸如New Era Cap Company、XL Capital、Spire Systems和Adobe Systems这样的公司提供过咨询服务。Brian致力于宣传ColdFusion、Flex、Adobe AIR和Flash Platform如何提供比其他竞争技术更高的生产力和更丰富的美妙体验。
注:以上内容来自网络,本人不承担任何连带责任
文章转自:http://blog.youkuaiyun.com/chengyongli/archive/2008/03/12/2173955.aspx