Lesson 17. Accessing Server-side Objects


What You Will Learn

In this lesson, you will:

  • Use the <mx:WebService> tag to retrieve data from the server

  • Sort the collection returned from the server as result of the Web Service call

  • Declare the specific operations on the <mx:WebService> tag

  • Bind specific parameters to a Web Service operation

  • Upload a file to the server

  • Use the WebService ActionScript object to update data on the server

  • Implement a DataManager ActionScript class to centralize all your Web Service calls

  • Use the <mx:RemoteObject> tag to place an order on the server

  • Map a server object to an ActionScript class for data transfer between client and server

Approximate Time

This lesson takes approximately 2 hours to complete.

Lesson Files

Media:

Lesson17/assets/DataManager.as

Starting Files:

Lesson17/start/Dashboard.mxml

Lesson17/start/DataEntry.mxml

Lesson17/start/valueObjects/Product.as

Lesson17/start/valueObjects/OrderInfo.as

Lesson17/start/views/dataEntry/AddProduct.mxml

Lesson17/start/views/dataEntry/UpdateDeleteProd.mxml

Lesson17/start/managers/CategorizedProductManager.mxml

Lesson17/start/EComm.mxml

Lesson17/start/views/ecomm/Checkout.mxml

Lesson17/start/views/ecomm/OrderConf.mxml

Completed Files:

Lesson17/complete/Dashboard.mxml

Lesson17/complete/DataEntry.mxml

Lesson17/complete/valueObjects/Product.as

Lesson17/complete/valueObjects/OrderInfo.as

Lesson17/complete/views/dataEntry/AddProduct.mxml

Lesson17/complete/views/dataEntry/FileUpload.mxml

Lesson17/complete/views/dataEntry/UpdateDeleteProd.mxml

Lesson17/complete/managers/CategorizedProductManager.mxml

Lesson17/complete/EComm.mxml

Lesson17/complete/views/ecomm/Checkout.mxml

Lesson17/complete/views/ecomm/OrderConf.mxml

Lesson17/complete/managers/DataManager.as

Lesson17/complete/events/DataManagerResultEvent.as

Until now, the data that you have been displaying (available products, categories, sales data, and so on) has come from XML feeds or written into the application via MXML/ActionScript. In the real world, every application that you write will have three logic areas: the client, the business logic (logic that implements the requirement of the system), and the data it runs on. Although Adobe Flex is a great platform for developing your rich-client interface and can also be used to write business logic, from an architectural standpoint it is sometimes best to put your core business logic outside of your Flex application. For example, have the process that does a real-time evaluation of a checked-out state on a piece of data reside on the server and be called by the client before using access data to make sure it can still be used. In this example, you see it is best to implement the central business rules and data access in a location in which all the users accessing the system will have access. This best practice can be implemented in a variety of technologies and accessed from Flex in several different ways.

Confirmation screen after adding a new product

In this lesson, you will initially learn how to access code (server-side objects) written on the server to retrieve data to feed the Dashboard, update product information, and place an order. Then you will learn how the <mx:WebService> and <mx:RemoteObject> tags enable you to use both an industry standard and an open binary protocol to call this Server object. Because the data that defines a product is its picture, you will implement the ability to upload a file. Finally, you will write some high-level architectural features to assist you with centralizing your server access and passing data between the client and server tiers. The previous example shows the confirmation screen after a new product is added.

From this lesson going forward, all external access from the application will be using the local ColdFusion instance. Please refer to the appendix, "Setup Instructions," to learn how to install, set up, and run the ColdFusion server instance and application.




Adobe Flex 2.Training from the Source
Adobe Flex 2: Training from the Source
ISBN: 032142316X
EAN: 2147483647
Year: 2006
Pages: 225

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net