1、(5)An overview of how to build Flex applications using events, states, MXML components, and modules. (6)An introduction to developing a Flex application with real-time server data push. (7)How to boost productivity developing data-intensive applications using the Data Management service in LiveCycle
2、 Data Services. (8)An overview of model driven development using Flash Builder and LiveCycle Data Services to generate client and server-side code. (9)How to deploy a Flex application on a portal server. (10)Be sure to also watch the video Introduction to Flex 4 and Java integration.(11)To learn mor
3、e about the technologies used to build these applications, read The technologies for building Flex and Java applications article.Client/server architecture Flex and Java applications use a multi-tier architecture where the presentation tier is the Flex application, the business or application tier i
4、s the Java EE server and code, and the data tier is the database. You can write the back-end code just as you normally would for a Java application, modeling your objects, defining your database, using an object-relational framework such as Hibernate or EJB 3, and writing the business logic to query
5、 and manipulate these objects. The business tier must be exposed for access via HTTP from the Flex application and will be used to move the data between the presentation and data tiers. Typical HTML applications consist of multiple pages and as a user navigates between them, the application data mus
6、t be passed along so the application itself (the collection of pages and functionality it consists of) can maintain state. In contrast, Flex applications, by nature, are stateful. A Flex application is embedded in a single HTML page that the user does not leave and is rendered by Flash Player. The F
7、lex application can dynamically change views and send and retrieve data asynchronously to the server in the background, updating but never leaving the single application interface (see Figure 1) (similar to the functionality provided by the XMLHttpRequest API with JavaScript.) Figure 1. The client/s
8、erver architecture.Client/server communicationFlex applications can communicate with back-end servers using either direct socket connections or more commonly, through HTTP. The Flex framework has three remote procedure call APIs that communicate with a server over HTTP: HTTPService, WebService, and
9、RemoteObject. All three wrap Flash Players HTTP connectivity, which in turn, uses the browsers HTTP library. Flex applications cannot connect directly to a remote database.You use HTTPService to make HTTP requests to JSP or XML files, to RESTful web services, or to other server files that return tex
10、t over HTTP. You specify the endpoint URL, listener functions (the callback functions to be invoked when the HTTPService request returns a successful or unsuccessful response), and a data type for the returned data (what type of data structure it should be translated into once received in the Flex a
11、pplication). You can specify the data to be handled as raw text and assigned to a String variable or converted to XML, E4X, or plain old ActionScript objects. If you get back JSON, you can use the Adobe Flex corelib package of classes to deserialize the JSON objects into ActionScript objects. To mak
12、e calls to SOAP based web services, you can use the HTTPService API or the more specialized WebService API, which automatically handles the serialization and deserialization of SOAP formatted text to ActionScript data types and vice versa. The third option for making remote procedure calls is to use
13、 the RemoteObject API. It makes a Flash Remoting request to a method of a server-side Java class that returns binary Action Message Format over HTTP. When possible, use Flash Remoting whose binary data transfer format enables applications to load data up to 10 times faster than with the more verbose
14、, text-based formats such as XML, JSON, or SOAP (see Figure 2). To see a comparison of AMF to other text-based serialization technologies, see James Wards Census RIA Benchmark application.Figure 2. Methods for connecting Flex and Java.Flash Remoting Flash Remoting is a combination of client and serv
15、er-side functionality that together provides a call-and-response model for accessing server-side objects from Flash Platform applications as if they were local objects. It provides transparent data transfer between ActionScript and server-side data types, handling the serialization into Action Messa
16、ge Format (AMF), deserialization, and data marshaling between the client and the server.Flash Remoting uses client-side functionality built in to Flash Player and server-side functionality that is built in to some servers (like ColdFusion and Zend) but must be installed on other servers (as BlazeDS
17、or LiveCycle Data Services on Java EE servers, WebORB or FluorineFX on .NET servers, the Zend framework or amfphp on PHP servers, and more). See the technologies for building Flex and Java applications article for more details about BlazeDS and LiveCycle Data Services.BlazeDS and LiveCycle Data Serv
18、ices use a message-based framework to send data back and forth between the client and server. They provide Remoting, Proxying, and Messaging services, and for LiveCycle, an additional Data Management service. The Flex application sends a request to the server and the request is routed to an endpoint
19、 on the server. From the endpoint, the request is passed to the MessageBroker, the BlazeDS and LiveCycle Data Services engine that handles all the requests and routes them through a chain of Java objects to the destination, the Java class with the method to invoke (see Figure 3).Figure 3. Flash Remo
20、ting architecture.AMFAMF is a binary format used to serialize ActionScript objects and facilitate data exchange between Flash Platform applications and remote services over the Internet. Adobe publishes this protocol; the latest is AMF 3 Specification for ActionScript 3. You can find tables listing
21、the data type mappings when converting from ActionScript to Java and Java to ActionScript here. For custom or strongly typed objects, public properties (including those defined with get and set methods) are serialized and sent from the Flex application to the server or from the server to the Flex ap
22、plication as properties of a general 0bject. To enable mapping between the corresponding client and server-side objects, you use the same property names in the Java and ActionScript classes and then in the ActionScript class, you use the RemoteClass metadata tag to create an ActionScript object that
23、 maps directly to the Java object. Here is an example Employee ActionScript class that maps to a server-side Employee Java DTO located in the services package on the server.package valueobjects.Employee Bindable RemoteClass(alias=services.Employee) public class Employee public var id:int; public var
24、 firstName:String; public var lastName: (.) Installing BlazeDS or LiveCycle Data ServicesTo use Flash Remoting with BlazeDS or LiveCycle Data Services, you need to install and configure the necessary server-side files. For BlazeDS, you can download it as a WAR file which you deploy as a web applicat
25、ion or as a turnkey solution. The turnkey download contains a ready-to-use version of Tomcat in which the the BlazeDS WAR file has already been deployed and configured along with a variety of sample applications. Similarly, for LiveCycle Data Services, the installer lets you choose to install LiveCy
26、cle with an integrated Tomcat server or as a LiveCycle Data Services web application.In either scenario a web application called blazeds or lcds (usually appended by a version number) is created. You can modify and build out this application with your Java code, or more typically, you can copy the J
27、AR files and configuration files the blazeds or lcds web application contains and add them to an existing Java web application on the server (see Figure 4). Figure 4. The required BlazeDS or LiveCycle Data Services files.Modifying web.xmlIf copying the files to a different web application, you also
28、need to modify the web.xml file to define a session listener for HttpFlexSession and a servlet mapping for MessageBroker, which handles all the requests and passes them off to the correct server-side Java endpoints. You can copy and paste these from the original blazeds or lcds web application web.x
29、ml file. listener-classflex.messaging.HttpFlexSession/listener- MessageBroker Servlet -servletservlet-nameMessageBrokerServletdisplay-name/display-nameservlet-classflex.messaging.MessageBrokerServletinit-paramparam-nameservices.configuration.fileparam-value/WEB-INF/flex/services-config.xml/init-paramload-on-startup1/servletservlet-mappingurl-pattern/messagebroker/*/servlet-mapping Optionally, you may also want to copy and paste (and uncomment) the mapping for RDSDispatchServlet, which
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1