Chapter 4. Connecting to web services

 

This chapter covers

  • Model View Presenter
  • Event dispatching and handling
  • Calling a web service
  • Interfaces and views

In chapter 3 you designed the UI for the Flex application, but it won’t be useful until it can communicate with a server-side component. In this chapter you’re going to continue building up the client-side application. Many Flex books attempt to hide complexity when dealing with client-side code and ActionScript, usually by having you create all your WebService components and event handling code in your MXML files. This solution, as many developers agree, does not scale well and quickly shows its warts in any but the most trivial application.

We’ve decided instead to architect the client-side code in such a manner as to not only scale well, but also isolate your View from Presentation and from external services. This allows the application to be flexible enough to easily refactor and replace one implementation of external service with another with minimal code changes. You could, therefore, painlessly change your application from calling web services to leveraging BlazeDS as you’ll see in chapter 5. You’ll do this by using MVP.

4.1. Model View Presenter

4.2. Web services in Flex

4.3. Dispatching and handling events

4.4. Creating Issue and Comment transfer objects

4.5. Enhancing the master view

4.6. Enhancing the detail view

4.7. Enhancing the comments view

4.8. Adding a pop-up form for editing comments

4.9. Summary