Comparing Flex data management to other technologies

The way that Flex works with data sources and data is different from other web application environments, such as JSP, ASP, and ColdFusion. Data access in Flex applications also differs significantly from data access in applications created in Macromedia Flash MX 2004. This section describes some of the differences.

Client-side processing and server-side processing

Unlike a set HTML templates created using JSPs and servlets, ASP, or CFML, the files in a Flex application are compiled on the server into a binary SWF file that is sent to the client. When a Flex application makes a request to an external data service, the SWF file is not recompiled and no page refresh is required.

The following example shows MXML code for calling a web service. When a user clicks the Button control, client-side code calls the web service and result data is returned into the binary SWF file without a page refresh. The result data is then available to use as dynamic content within the application.

...
   <!-- Define the web service connection (the specified WSDL URL is not functional). -->
   <mx:WebService id="WeatherService" wsdl="/ws/WeatherService?wsdl">
...
   <mx:Button label="Get Weather" 
      click="WeatherService.GetWeather(input.text);"/>
...

The following example shows JSP code for calling a web service using a JSP custom tag. When a user requests this JSP, the web service request is made on the server instead of on the client, and the result is used to generate content in the HTML page. The application server regenerates the entire HTML page before sending it back to the user's web browser.

<%@ taglib prefix="web" uri="webservicetag" %>

<% String str1="BRL";
String str2="USD";%>

<!-- Call the web service. -->
<web:invoke
   url="http://www.itfinity.net:8008/soap/exrates/default.asp"
   namespace="http://www.itfinity.net/soap/exrates/exrates.xsd"
   operation="GetRate"
   resulttype="double"
   result="myresult">
   <web:param name="fromCurr" value="<%=str1%>"/>
   <web:param name="ToCurr" value="<%=str2%>"/>
</web:invoke>

<!-- Display the web service result. -->
<%= pageContext.getAttribute("myresult") %>

Data source access

Another difference between Flex and other web application technologies is that you never communicate directly with a data source in Flex. You use a Flex data service component to connect to a server-side service that interacts with the data source.

The following example shows one way to access a data source directly in a ColdFusion page:

...
<CFQUERY DATASOURCE="Dsn"
   NAME="myQuery">
   SELECT * FROM table
</CFQUERY>
...

To get similar functionality in Flex, you use an HTTP service, a web service, or a remote object service to call a server-side object that returns results from a data source.

Flash MX data management

Flash MX 2004 and Flex provide different data management architectures. These architectures were developed to meet the needs of the respective authoring environments and user communities. Flash MX 2004 provides a set of data components, which includes XMLConnector, WebServices Connector, DataSet, DataHolder, RDMBSResolver, and XUpdateResolver. These components are designed for use in the Flash MX 2004 authoring environment. Although some of the functionality of these components overlaps with features found in Flex, they are not based on the same architecture.

Flash MX 2004 also has its own data-binding feature that works in conjunction with the Flash MX data components, and is a completely different feature than Flex data binding.

In Flash MX 2004, you can also use Macromedia Flash Remoting MX to connect to server-side data sources. You use the NetServices ActionScript API to work with Flash Remoting MX in Flash MX 2004. When working with the Flex remote object services, you can choose to use the AMF binary transport protocol instead of SOAP. AMF is the protocol used in Flash Remoting MX, but AMF support in remote object services does not include all the features of the Flash Remoting MX product. AMF support in remote object services gives you the choice of a binary protocol when accessing Java objects.


Version 1.5

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000686.htm