Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Flash Builder 4 and Flex 4 Bible- P18: When Macromedia first released Flash MX in 2002, the product was branded as the new way to build Rich Internet Applications (known by the acronym RIA). The term was invented at Macromedia to describe a new class of applications that would offer the benefits of being connected to the Internet, including access to various types of Web-based services, but would solve many of the nagging issues that had been inherent in browser-based applications since the mid-1990s | Chapter 26 Integrating Flex Applications with BlazeDS and Java Note Desktop Flex applications deployed with Adobe AIR don t need to use the Proxy Service. These applications aren t downloaded from the Web at runtime so they aren t subject to the rules of the Web security sandbox and can make runtime requests directly to any domain. The application in Listing 26.2 uses a proxied request for data in an XML file stored on the server. LISTING 26.2 A Flex application using the Proxy Service xml version 1.0 encoding utf-8 s Application xmlns fx http ns.adobe.com mxml 2009 xmlns s library ns.adobe.com flex spark xmlns mx library ns.adobe.com flex mx fx Declarations s HTTPService id contactService useProxy true url http 127.0.0.1 8400 blazeds flex4bible data contacts.xml result resultHandler event fault faultHandler event fx Declarations s layout s VerticalLayout horizontalAlign center paddingTop 20 s layout fx Script CDATA import mx.collections.ArrayCollection import mx.controls.Alert import mx.rpc.events.FaultEvent import mx.rpc.events.ResultEvent Bindable private var myData ArrayCollection private function resultHandler event ResultEvent void myData event.result.contacts.row private function faultHandler event FaultEvent void Alert.show event.fault.faultString event.fault.faultCode fx Script s Button label Get Data click contactService.send mx DataGrid dataProvider myData s Application 821 Part IV Integrating Flex Applications with Application Servers On the Web The code in Listing 26.2 is available in the Web site files as DefaultProxyDestination.mxml in the src folder of the chapter26 project. When you run the application in its current state it correctly downloads and displays the requested data. If you remove the HTTPService component s useProxy property or set it to false the request fails because the domain of the XML file and the domain from which the application is downloaded don t match. The result is a security fault as shown in Figure 26.5. FIGURE 26.5 A Flex