Adobe
产品
Acrobat
Creative Cloud
创意套装
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
更多产品
解决方案
数字营销
数字媒体
教育
金融服务业
政府部门
网页体验管理
更多解决方案
学习帮助下载公司
商店
在线商店
批量许可
查找经销商
搜索
 
信息 登录
欢迎,我的支持
我的帐户
注销
为何登录?登录后可以管理您的帐户,访问试用版下载、产品扩展和社区区域等。
Adobe
产品 分类 购买   搜索  
解決方案 公司
学习
登录 注销 我的货物 我的支持
Date Date
Qty:
Subtotal
Checkout
Adobe 开发者中心 / Flex 开发人员中心 /

Set up and build your first Flex and ColdFusion application – Part 3: Use ColdFusion and Flash Builder 4 to create an application

by Trilemetry

Trilemetry
  • Trilemetry, Inc.

Content

  • Create a Flash Builder project
  • Connect to the ColdFusion server
  • Introspect and import a CFC
  • Create a simple employee data display

Created

22 March 2010

页面工具

在 Facebook 上共享
在 Twitter 上共享
在 LinkedIn 上共享
书签
打印

Tags

要求

必备知识

This tutorial is intended for:

  • Developers who are exploring tutorials in the Flex and ColdFusion mini learning center that are based on the Fictitious Sales Planner example.
  • Experienced ColdFusion developers without previous Adobe Flex framework or Adobe Flash Builder 4 experience.
  • ColdFusion developers who are familiar with ColdFusion components.

用户级别

全部

必需产品

  • ColdFusion (Download trial)
  • Flash Builder (Download trial)

范例文件

  • f4cf_fictitious_db.zip (75 KB)
  • f4cf_generated_cfcs.zip (4 KB)

In Part 1, you learned how to set up a ColdFusion data source and Flash Builder project. In Part 2, which is optional, you generated the ColdFusion components (CFCs) using ColdFusion Builder. In this section, you will set up a Flash Builder data service project with ColdFusion for use with the Fictitious Sales Planner sample application.

Create a Flash Builder project

A Flash Builder project is similar to a Dreamweaver site. You create a project to store and organize your code files. Follow these steps to create a Flash Builder project:

  1. Open Flash Builder 4.

    Note: We assume that you are working with the standalone (not the plug-in) version of Flash Builder 4. You can install the plug-in version if you are already using Eclipse for your programming environment. However, you will likely see some minor variations in the following steps. We also assume that you have a local, standalone installation of ColdFusion. You may need to make changes to the paths based on your custom installation.

  2. Select File > New > Flex Project as shown in Figure 1.
Create a new Flash Builder project.
Figure 1. Create a new Flash Builder project.

You will get the new project dialog box. Set up your new project as shown in Figure 2:

  • Name the project F4CF_Importing_CFC.
  • Be sure to use the default location for this example.

In the Server technology section of the dialog box, select ColdFusion from the Application server type drop-down menu. (Note that the Use remote object access service check box is selected by default when you select a server technology.)

  • Select the ColdFusion Flash Remoting option.
Set up your new project in the New Flex Project dialog box.
Figure 2. Set up your new project in the New Flex Project dialog box.
  1. Click Next.

Connect to the ColdFusion server

Follow these steps to configure your Flash Builder project to work with your ColdFusion server:

  1. In the Configure ColdFusion Server dialog box, select the options for your ColdFusion installation type.

    Figure 3 shows the settings if you are using the default installation of ColdFusion in Standalone mode on a PC.

Specify your ColdFusion server configuration.
Figure 3. Specify your ColdFusion server configuration.

Note: If you have used the default installation of ColdFusion in Standalone mode for a Mac OS X computer, your ColdFusion settings will likely be:

  • ColdFusion root folder: /Applications/ColdFusion9
  • Built-in ColdFusion web server web root: /Applications/ColdFusion9/wwwroot
  • Built-in ColdFusion web server root URL: http://localhost:8500
  1. Click the Validate Configuration button to ensure that the settings are correct.

    Note that the location of the Output folder is located within the ColdFusion server web root.

    Flash Builder automatically creates a folder named based on the project name and appended with –debug.

    In this case, the F4CF_Importing_CFC-debug folder is where Flash Builder will place the compiled Flash SWF and HTML wrapper files.

    Note: If you have the default installation of ColdFusion in Standalone mode for a Mac OS X computer, your Output folder setting is likely /Applications/ColdFusion9/wwwroot/F4CF_Importing_CFC-debug.

    Remember that Flash source files, unlike ColdFusion source files, are not deployed to the web server.

    Instead, you compile the source into a SWF file that is referenced in HTML wrapper files. The SWF and HTML files are uploaded to the server.

  2. Click Finish to create the Flash Builder project.

You will see the F4CF_Importing_CFC project in the Package Explorer, shown in Figure 4. Note also that the MXML application file with the same name is created and opened for editing. Note that Figure 4 shows the MXML Editor tab in Design mode. Click the Source button below the tab to see the Editor in code view.

The Flash Builder project in the Package Explorer
Figure 4. The Flash Builder project in the Package Explorer

The Flex framework provides two programming languages: ActionScript, which is a fully object-oriented language, and MXML, which is an XML-based language with similar syntax to CFML.

Introspect and import a CFC

Introspect and import a CFC

Now that your database, data source, and Flash Builder project are set up, you are ready to learn how easy it is to retrieve data from a CFC method and bind it to a Flex user interface element. Time to complete: 5 minutes.

Downloading the ColdFusion component

ColdFusion components are a way of organizing your business logic into reusable code. They were introduced in ColdFusion MX and replace the inline database query construct. In other words, instead of putting a cfquery tag at the top of your CFML page, you invoke the query that is placed into a CFC method, passing in arguments as necessary.

Note: Refer to the article Understanding the role of CFCs in Flex application development for more information on CFCs.

Note: If you generated the CFC's using ColdFusion Builder, then skip to Using the Data Services wizard to import a CFC section. Otherwise, continue with the following steps to download the CFC’s needed to continue with this exercise.

  1. Download and unzip the provided f4cf_ generated_cfcs.zip file on your local disk if you haven’t done so already.
  2. Move the F4CF_FictitiousSalesPlanner folder to the \\wwwroot directory.

Using the Data Services wizard to import a CFC

Next, you will import the CFC into the project using the Data/Services view in Flash Builder:

  1. Locate the Data/Services view in Flash Builder shown in Figure 5.

    (If the view is not open, select Window > Data/Services.)

The Data/Services view.
Figure 5. The Data/Services view.
  1. Click the Connect to Data/Service link to run the Data Services wizard.

    Note: You can also select Data > Connect to Data/Service to open the Data Services wizard.

  2. Select ColdFusion for the service type (see Figure 6).
Select the ColdFusion data service type.
Figure 6. Select the ColdFusion data service type.
  1. Click Next.
  2. For CFC Location, browse to C:\ColdFusion9\wwwroot\F4CF_FictitiousSalesPlanner\SALESTARGETSService.cfc and Click Open. See Figure 7.
Configure the ColdFusion Service.
Figure 7. Configure the ColdFusion Service.
  1. Click Next.
  2. In the Remote Service Authentication dialog box, shown in Figure 8, enter your RDS username and password.

Note: Be sure to have RDS enabled in the ColdFusion Administrator. Remember that the default username is admin.

Enter your credentials to authenticate RDS access.
Figure 8. Enter your credentials to authenticate RDS access.
  1. Click OK.

    Flash Builder accesses the CFC, introspects it, and returns information about the available operations and data types associated with those operations. You will see each method in the CFC displayed in the Service Operations window shown in Figure 9.

The Service Operations dialog displays the CFC methods.
Figure 9. The Service Operations dialog displays the CFC methods.
  1. Click Finish.

Flash Builder creates the service. You may see the instructions shown in Figure 10, if you have not previously selected the check box in the lower left corner of the Using Remote Services dialog box.

Instructions for using the remote service.
Figure 10. Instructions for using the remote service.

The rest of this tutorial steps you through these instructions.

  • Click OK to dismiss the Using Remote Services dialog box.
  • Locate the Data/Services view to see the CFC operations shown in Figure 11.
The introspected CFC operations.
Figure 11. The introspected CFC operations.

Note that the getAllSALESTARGETS() method name is followed by SALESTARGETS[]. When Flash Builder introspected  the CFC and provided information about the methods, it mapped the ColdFusion query that is returned from this operation to an Array data type.                    

Create a simple employee data display

Now that the CFC has been introspected into Flash Builder and the Flash Builder project is set up, you will use the returned data to create a simple employee data display. Time to complete: 5 minutes.

Reviewing the data types

In this section, you will review the SALESTARGETS Data Type within the Data Services view.

Expand the Data Types category in the Data/Services view to see that the SALESTARGETS data type is defined as an object that includes EMAIL, FIRSTNAME, and LASTNAME properties (see Figure 12).

The SALESTARGETS data type.
Figure 12. The SALESTARGETS data type.

Binding data to a Flex component

This section demonstrates how to bind the SALESTARGETS data type to a DataGrid component:

  1. Switch to Design mode in Flash Builder by clicking the Design button below the Editor tab (see Figure 13).
The Design view button.
Figure 13. The Design view button.
  1. Locate the DataGrid control of the Components view (see Figure 14).
The Flex Builder Components panel.
Figure 14. The Flex Builder Components panel.
  1. Drag and drop the DataGrid component into the Design view of the F4CF_Importing_CFC.mxml file as shown in Figure 15.
Add the DataGrid control to your application.
Figure 15. Add the DataGrid control to your application.
  1. Drag and drop the getAllSalesTargets() CFC function from the Data/Services view onto the DataGrid control to populate it with the SALESTARGETS data type.

    Leave the defaults in the Bind to Data dialog window and Click OK.

    The DataGrid control now has columns that match the properties in the SALESTARGETS data type. (see Figure 16)

The bound DataGrid control.
Figure 16. The bound DataGrid control.
  1. Select File > Save to save the MXML file.
  2. Click the Run (green round) button to test the file (see Figure 17).
Click the Run button.
Figure 17. Click the Run button.

Figure 18 shows the DataGrid control populated with the CFC data. Note that Flash Builder has opened the HTML wrapper file from the F4CF_Importing_CFC folder in the web root.

The DataGrid component populated by the SALESTARGETS data type.
Figure 18. The DataGrid component populated by the SALESTARGETS data type.

Where to go from here

In this tutorial, you set up the an Apache Derby sample database, and a ColdFusion data source. If you chose to, you generated a CFC using ColdFusion Builder. Then you set up a Flash Builder project to work with ColdFusion server technology. Finally, you experienced how easy it is to retrieve data from a CFC method and bind it to a Flex user interface element. To learn more how to build ColdFusion and Flex applications, visit the Flex and ColdFusion page in Flex Developer Center.

More Like This

  • Set up and build your first Flex and ColdFusion application – Part 1: Database setup
  • Set up and build your first Flex and ColdFusion application – Part 2: Generating ColdFusion components
  • Understanding Flex in the client/server model
  • Working with Doctrine 2, Zend AMF, Flex, and Flash Builder
  • Deploying a Flex application with ColdFusion URL variables
  • Understanding the role of CFCs in Flex application development
  • Introducing the MXML and ActionScript languages
  • Sending and receiving mobile text messages with Flex, ColdFusion, and BlazeDS
  • 管理数据
  • 用Flash Builder 4 beta建立连接BlazeDS远程端的Flex应用程序

产品

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • 移动应用程序
  • Photoshop
  • Touch Apps

解决方案

  • 数字营销
  • 数字媒体
  • 网页体验管理

行业

  • 教育
  • 金融服务业
  • 政府部门

帮助

  • 产品帮助中心
  • 订货和退货
  • 下载和安装
  • 我的 Adobe

学习

  • Adobe 开发人员连接
  • Adobe TV
  • 培训和认证
  • 论坛
  • 设计中心

购买方式

  • 在线商店
  • 批量许可
  • 查找经销商

下载

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

公司

  • 新闻编辑室
  • 合作伙伴计划
  • 公司社会责任
  • 工作机会
  • 投资者关系
  • 事件
  • 法律
  • 安全
  • 联系 Adobe
选择您的地区 中国(更改)
选择您的地区 关闭

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

使用条款 | 隐私政策和 Cookies (更新)

京 ICP 备 10217899 号 京公网安备 110105010404