| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <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" |
| minWidth="955" minHeight="850" |
| creationComplete="employeeService.send()" |
| xmlns:components="components.*"> |
| |
| <!-- Exercise 3.03: Dispatching a value object from the custom component --> |
| |
| <!-- Styles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> |
| |
| <fx:Style source="Styles.css"/> |
| |
| <!-- Script ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> |
| |
| <fx:Script> |
| <![CDATA[ |
| import mx.collections.ArrayCollection; |
| import mx.controls.Alert; |
| import mx.rpc.events.FaultEvent; |
| import mx.rpc.events.ResultEvent; |
| |
| import valueObjects.Employee; |
| |
| // variable declarations ------------------------------------ |
| |
| [Bindable] |
| private var employees:ArrayCollection = new ArrayCollection(); |
| |
| // getter/setters ------------------------------------------- |
| |
| |
| // helper methods ------------------------------------------- |
| |
| |
| // event handlers ------------------------------------------- |
| |
| protected function employeeService_resultHandler(event:ResultEvent):void
|
| {
|
| var employeeData:ArrayCollection = event.result.employees.employee; |
| var employee:Employee; |
| |
| for each (var emp:Object in employeeData)
|
| {
|
| employee = new Employee(); |
| employee.firstName = emp.firstName; |
| employee.lastName = emp.lastName; |
| employee.id = emp.id; |
| employee.title = emp.title; |
| employee.email = emp.email; |
| employee.managerID = emp.managerID; |
| employee.department = emp.department; |
| employee.location = emp.location; |
| employee.deskLocation = emp.deskLocation; |
| employee.city = emp.city; |
| employee.state = emp.state; |
| employee.countryCode = emp.countryCode; |
| employee.postalCode = emp.postalCode; |
| employee.directDial = emp.directDial; |
| employee.hireDate = emp.hireDate; |
| employee.evaluation = emp.evaluation; |
| employee.phone = emp.phone; |
| employees.addItem(employee);
|
| } |
|
|
| } |
| |
| protected function employeeService_faultHandler(event:FaultEvent):void
|
| {
|
| Alert.show(event.fault.faultString,"Fault Information");
|
| } |
| |
| ]]> |
| </fx:Script> |
| |
| <!-- Declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> |
| |
| <fx:Declarations> |
| |
| <s:HTTPService id="employeeService" |
| url="http://adobetes.com/f45iaw100/remoteData/employees.xml" |
| result="employeeService_resultHandler(event)" |
| fault="employeeService_faultHandler(event)"/> |
| |
| </fx:Declarations> |
| |
| <!-- UI components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> |
| |
| <s:Label x="10" y="34" |
| width="690" height="40" |
| text="Employee Portal: Vehicle Request Form" |
| styleName="titleHeader"/> |
| |
| <components:VehicleRequestForm employees="{employees}"/> |
| |
| </s:Application> |