| <?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:View xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:employeeservice="services.employeeservice.*" |
| title="HomeView"> |
| <fx:Script> |
| <![CDATA[ |
| import mx.events.FlexEvent; |
| import mx.rpc.events.ResultEvent; |
| import spark.events.IndexChangeEvent; |
| |
| protected function empList_creationCompleteHandler(event:FlexEvent):void |
| { |
| getEmployeesSummaryResult.token = employeeService.getEmployeesSummary(); |
| } |
| protected function doSearch(event:Event):void |
| { |
| this.addElement(busyIndicator); |
| if(searchTxt.text!="") |
| { |
| getEmployeesSummaryResult.token = employeeService.getEmployeesSummaryByName(searchTxt.text); |
| } |
| else |
| { |
| getEmployeesSummaryResult.token = employeeService.getEmployeesSummary(); |
| } |
| } |
| protected function getEmployeesSummaryResult_resultHandler(event:ResultEvent):void |
| { |
| this.removeElement(busyIndicator); |
| } |
| protected function empList_changeHandler(event:IndexChangeEvent):void |
| { |
| navigator.pushView(DetailView,empList.selectedItem.id); |
| } |
| ]]> |
| </fx:Script> |
| <fx:Declarations> |
| <s:CallResponder id="getEmployeesSummaryResult" result="getEmployeesSummaryResult_resultHandler(event)"/> |
| <employeeservice:EmployeeService id="employeeService"/> |
| </fx:Declarations> |
| <s:titleContent> |
| <s:TextInput id="searchTxt" width="100%" |
| prompt="Employee Name" enter="doSearch(event)"/> |
| </s:titleContent> |
| <s:actionContent> |
| <s:Button id="searchBtn" click="doSearch(event)"> |
| <s:icon> |
| <s:MultiDPIBitmapSource source160dpi="@Embed('assets/search160.png')" |
| source240dpi="@Embed('assets/search240.png')" |
| source320dpi="@Embed('assets/search320.png')"/> |
| </s:icon> |
| </s:Button> |
| <s:Button id="addBtn"> |
| <s:icon> |
| <s:MultiDPIBitmapSource source160dpi="@Embed('assets/add160.png')" |
| source240dpi="@Embed('assets/add240.png')" |
| source320dpi="@Embed('assets/add320.png')"/> |
| </s:icon> |
| </s:Button> |
| </s:actionContent> |
| <s:List id="empList" left="0" right="0" top="0" bottom="0" |
| creationComplete="empList_creationCompleteHandler(event)" |
| change="empList_changeHandler(event)"> |
| <s:AsyncListView list="{getEmployeesSummaryResult.lastResult}"/> |
| <s:itemRenderer> |
| <fx:Component> |
| <s:IconItemRenderer iconHeight="50" iconWidth="50" iconFunction="getPhotoURL" |
| labelFunction="getEmployeeFullName" messageField="title"> |
| <fx:Script> |
| <![CDATA[ |
| private function getPhotoURL(item:Object):String |
| { |
| return "http://localhost:10088/TestDrive/photos/" + item.photofile; |
| } |
| private function getEmployeeFullName(item:Object):String |
| { |
| return item.firstname + " " + item.lastname; |
| } |
| ]]> |
| </fx:Script> |
| </s:IconItemRenderer> |
| </fx:Component> |
| </s:itemRenderer> |
| </s:List> |
| <s:BusyIndicator id="busyIndicator" verticalCenter="0" horizontalCenter="0" symbolColor="red"/> |
| </s:View> |