MACROMEDIA COLDFUSION MX 7.0.2-USING COLDFUSION MX WITH FLEX 2 Using Manual - page 40
40
Using the Flex Data Service Assembler
true true to enable the data services adapter: 1. Copy the following coldfusion-specific sections (cf-dataservice-rtmp and cf-polling-amf) from the sample services-config.Xml file to the section of the web application flex-messaging-service.Xml f...
Page 42
42 using the flex data service assembler the sample services-config.Xml file is located in the c:\fds2\resources\config folder, and the web application flex-messaging-service.Xml file is located in the c:\fds2\jrun4\servers\default\samples\web-inf\flex folder when you install flex in the default loc...
Page 43
Application development and deployment process 43 selecting a methodology when you create your coldfusion cfcs, you can put the database manipulation functionality directly in the methods in the assembler cfc and create a value object cfc, which is a cfc that contains property definitions and relate...
Page 44
44 using the flex data service assembler the arguments are as follows: ■ fillargs is a list of arguments to pass to the fill method ■ item is the record to check to determine if it is in the result set ■ iscreate indicates whether the record is new a sample fillcontains method, which determines whet...
Page 45
Enabling ssl 45 you can set the cerdentials by doing either of the following: ■ specifying credentials in actionscript ■ specifying credentials in the flex destination specifying credentials in actionscript to specify credentials in actionscript, you use the setremotecredentials() method, as in the ...
Page 46
46 using the flex data service assembler to enable ssl, you do the following: ■ create the keystore ■ configure flex ■ enable ssl in the coldfusion mx administrator to create the keystore: 1. Generate the ssl server (coldfusion) keystore file by using the keytool utility, with a command similar to t...
Page 47
Data translation 47 the previous example specifies the location of the keystore for flex data services with integrated jrun, installed using the default settings. If you are using a different server, specify the location of the cacerts file for the jre that you are using. For example, if you are usi...
Page 48
48 using the flex data service assembler example application this section describes creating a flex application that uses the coldfusion data service adapter and flex data service assembler so that a coldfusion component handles the back- end database management. You can download the source code for...
Page 49
Example application 49 ". Sql was :" & cfcatch.Sql> creating the sync method the sync method has a specific signature. The sync method accepts an array as its argument and have a return value of an array. The arrray that the sync method accepts contains java changeobjects, which flex creates and doc...
Page 50
50 using the flex data service assembler the sync method calls the private methods docreate , doupdate , and dodelete . If an error occurs, the method updates the change object with the failure to inform the flex application that the change was not processed. The changeobject has two apis, processed...
Page 51
Example application 51 ". Sql was :" & cfcatch.Sql> ". Sql was :" & cfcatch.Sql> ". Sql was :" & cfcatch.Sql> ". Sql was :" & cfcatch.Sql> ". Sql was :" & cfcatch.Sql>.
Page 52
52 using the flex data service assembler creating the count method the count method returns the number of records that would be returned by the fill method. The return type of the count method is numeric. It appears as follows: returntype="samples.Contact.Contact[]" access="remote"> ". Sql was :" & ...
Page 53
Example application 53 creating the get method the get method has a specific signature. It returns one record from the database, as a cfc instance. It appears as follows: access="remote"> had a value of #key#.")> value of #key#.")> was :" & cfcatch.Sql> access="remote"> had a value of #key#.")> valu...
Page 54
54 using the flex data service assembler creating the dao cfc you create the dao cfc to perform direct manipulations of the back-end database. The dao cfc appears as follows: returntype="samples.Contact.Contact[]"> select contactid, firstname, lastname, address, city, state, zip, phone from contacts...
Page 55
Example application 55 arrayappend(ret, obj); returntype="void"> type="samples.Contact.Contact"> insert into contacts(firstname, lastname, address, city, state, zip, phone) values ( cfsqltype="cf_sql_varchar" />, cfsqltype="cf_sql_varchar" />, "cf_sql_varchar" />, , "cf_sql_varchar" />, , ) select c...
Page 56
56 using the flex data service assembler and city = cfsqltype="cf_sql_varchar" /> and state = cfsqltype="cf_sql_varchar" /> and zip = cfsqltype="cf_sql_varchar" /> and phone = cfsqltype="cf_sql_varchar" /> order by contactid desc arguments.Contacts.Setcontactid(qgetid.Contactid); returntype="void"> ...
Page 57
Example application 57 returntype="void"> type="samples.Contact.Contact"> delete from contacts where contacts.Contactid = value="#arguments.Contacts.Getcontactid()#" cfsqltype="cf_sql_integer" /> returntype="void"> type="samples.Contact.Contact"> delete from contacts where contacts.Contactid = value...
Page 58
58 using the flex data service assembler creating the value object cfc to create the value object to return to flex, you create a cfc by using the cfproperty tag and including get and set methods. The value object cfc appears as follows: //initialize the cfc with the default properties values. This....
Page 59
Example application 59 returntype="any"> returntype="any"> returntype="void"> returntype="void"> returntype="any"> returntype="any"> returntype="void"> returntype="void"> returntype="any"> returntype="any"> returntype="void"> returntype="void"> returntype="any"> returntype="any"> returntype="void"> ...
Page 60
60 using the flex data service assembler returntype="void"> returntype="void"> returntype="any"> returntype="any"> returntype="void"> returntype="void"> returntype="any"> returntype="any"> returntype="void"> returntype="void"> specifying the destination in the data-management- config.Xml file to ens...
Page 61
Example application 61 3. To ensure that the channel is enabled, remove comments from around the channel definition for the cf-dataservice-rtmp channel. 4. Add the following destination to the data-management-config.Xml file: 0 samples.Contact.Contactassembler localhost remote false false false fill.
Page 62
62 using the flex data service assembler sync get count 5. Save the file. Run the application to run the application, browse to the contactmgr.Mxml file. The flex contact manager application theflex contact manager application includes the following files: ■ contactmgr.Mxml ■ hourglass.Mxml ■ mini.M...
Page 63
Example application 63 // the following is sample code and is subject to all restrictions on such code // as contained in the end user license agreement accompanying this product. // if you have received this file from a source other than adobe, // then your use, modification, or distribution of it ...
Page 64
64 using the flex data service assembler private function resulthandler(event:resultevent):void { hourglass.Remove(); if (event.Token.Kind == "create") { dg.Selectedindex = contacts.Length - 1; } else if (event.Token.Kind == "delete" && contacts.Length>0) { var index:int = event.Token.Index event.To...
Page 65
Example application 65 private function newcontact():void { dg.Selectedindex = -1; contact = new contact(); } private function updatecontact():void { var token:asynctoken; if (!Contacts.Contains(contact)) { hourglass.Show(this); ds.Createitem(contact); token = ds.Commit(); token.Kind = "create"; } e...
Page 66
66 using the flex data service assembler height="100%" change="contact=contact(dg.Selecteditem)" > > headertext="first name"/> name"/> height="100%" change="contact=contact(dg.Selecteditem)" > > headertext="first name"/> name"/> > headertext="first name"/> name"/> headertext="first name"/> name"/> n...
Page 67
Example application 67 text="{contact.Phone}"/> click="updatecontact()" width="60"/> visible="{dg.Selectedindex!=-1}" width="60"/> visible="{dg.Selectedindex!=-1}" width="60"/> hourglass.Mxml the hourglass.Mxml file contains the following: text="{contact.Phone}"/> click="updatecontact()" width="60"/...
Page 68
68 using the flex data service assembler import mx.Managers.Popupmanager; import mx.Core.Iflexdisplayobject; private static var dialog:iflexdisplayobject; public static function show(parent:displayobject):void { dialog = popupmanager.Createpopup(parent, hourglass, true); popupmanager.Centerpopup(dia...
Page 69
Example application 69 fault="faulthandler(event)" conflict="conflicthandler(event)"/> height="100%" editable="true"> editable="false"/> name"/> name"/> import mx.Controls.Alert; import mx.Data.Conflict; import mx.Data.Conflicts; import mx.Data.Events.Dataconflictevent; import mx.Rpc.Events.Faulteve...
Page 70
70 using the flex data service assembler contact.As the contact.As file contains the following: /////////////////////////////////////////////////////////////////////////// ///// // // copyright (c) 2003-2006 adobe macromedia software llc and its licensors. // all rights reserved. // the following is...
Page 71
Example application 71 wait.Png the wait.Png file appears as follows:.
Page 72
72 using the flex data service assembler.
Page 73
73 5 chapter 5 using the coldfusion extensions for flex builder the coldfusion extensions for flex builder include wizards that help generate code for common tasks and an extension that lets you connect to remote servers from adobe flex builder and eclipse. To use the coldfusion extensions for flex ...
Page 74
74 using the coldfusion extensions for flex builder about the coldfusion extensions for flex builder to make some common coding tasks easier, the coldfusion extensions for flex builder include the following: ■ eclipse rds support plug-in, which lets you access files and data sources on a coldfusion ...
Page 75
Eclipse rds support 75 7. Select the check box next to coldfusion_flexbuilder_feature.Zip, and then click next. 8. Select the i accept the terms in this license agreement option, and then click next. 9. Click finish. 10. Click install all. 11. When the installation is complete, click yes to restart ...
Page 76
76 using the coldfusion extensions for flex builder configuring rds before using rds, you must configure coldfusion servers. To configure any coldfusion servers that you want to connect to using rds: 1. In flex builder or eclipse, select window > preferences > rds configuration. 2. To configure the ...
Page 77
Eclipse rds support 77 using the rds fileview the rds fileview lists all the folders and files on the rds server. You use the navigation buttons as indicated in the following table: to rename a folder or file, right-click the folder or filename. Using the rds dataview the rds dataview lists all the ...
Page 78
78 using the coldfusion extensions for flex builder building queries in the rds query viewer to build and execute a query using the rds query viewer: 1. Click the rds query viewer icon on the rds dataview tab. The rds query viewer opens in its own tab, which means that if you have other documents op...
Page 79
Eclipse rds support 79 using visual query builder you use the query builder to define a sql statement. The following image shows the query builder user interface: to build a sql statement using the table pane and the properties panel: 1. Expand a data source. 2. Double-click the columns to be named ...
Page 80
80 using the coldfusion extensions for flex builder 4. (optional) specify sort order by doing the following: a. Locate the column in the properties panel. B. Click in the sort type cell of the column you want to sort by. C. Specify ascending or descending. D. (optional) if you specify multiple sort ...
Page 81
Coldfusion/flex application wizard 81 coldfusion/flex application wizard the coldfusion/flex application wizard creates coldfusion and flex files for a create, read, update, delete (crud) application. You specify the master, detail, and master/detail pages to include in the application, and the rela...
Page 82
82 using the coldfusion extensions for flex builder starting the coldfusion/flex application wizard to start the coldfusion/flex application wizard: 1. Configure your rds servers. For more information, see “configuring rds” on page 76 . 2. In flex builder, select file > new > other. 3. Under coldfus...
Page 83
Coldfusion/flex application wizard 83 to create a page: 1. Click the plus sign (+). 2. In the name: text box, enter the name for the page. 3. Select the page type (master, detail, or master/detail). 4. Click edit master form or edit detail form, depending on the type of form you are creating. The vi...
Page 84
84 using the coldfusion extensions for flex builder tips for creating applications with the coldfusion/ flex application wizard although the coldfusion/flex application wizard greatly simplifies creating crud applications, you should keep the following in mind to ensure that you create the applicati...
Page 85
Cfc to actionscript wizard 85 actionscript to cfc wizard the actionscript to cfc wizard lets you create a coldfusion component (cfc) based on an actionscript class file. To use the actionscript to cfc wizard: 1. In flex builder, go to the project navigator. 2. Right-click an actionscript class file....
Page 86
86 using the coldfusion extensions for flex builder rds crud wizard the remote development services (rds) crud wizard lets you dynamically create a coldfusion component (cfc) based on a table that is registered in the coldfusion administrator on a coldfusion server. To use the rds crud wizard, you m...
Page 87
Services browser 87 6. (optional) select the primary key column if a primary key is not defined in the database. 7. (optional) to specify the primary key column in addition to the other values specified in the cfc, select the primary key is controlled by the user option. If the primary key is automa...
Page 88
88 using the coldfusion extensions for flex builder browsing components the service browser lists the following components: ■ components that the coldfusion component browser lists the coldfusion component browser is located at cf_root/wwwroot/cfide/ componentutils/componentdoc.Cfm. ■ components tha...
Page 89
Services browser 89 managing web services the services browser lets you manage a list of web services by adding or deleting wsdl urls from a list. In addition, when you are editing a coldfusion file, you can use the services browser to generate cfml code to invoke a web service or to create a web se...
Page 90
90 using the coldfusion extensions for flex builder to create a web service object in coldfusion: 1. Place your mouse pointer where you want to insert the code. 2. View the list of web services. 3. Highlight a web service or a method in a web service and right-click. 4. Select insert cfinvoke. The c...