collapsing worthless "src" layer

This commit is contained in:
Dan Buch
2010-02-18 13:36:07 -05:00
parent ec2b4aba4f
commit 6317fe4f30
15 changed files with 4 additions and 8 deletions

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
include "dyn-employees.as";
]]>
</mx:Script>
<mx:HTTPService
id="employeesService"
url="http://examples.adobe.com/flex3/workingwithdata/employees.php"
resultFormat="e4x"
useProxy="false" />
<mx:ViewStack id="viewstack1" width="100%" height="100%" >
<mx:Canvas label="Form View" width="100%" height="100%">
<mx:Form horizontalCenter="0" verticalCenter="0"
backgroundColor="#FFFFFF">
<mx:FormItem label="Query Employees ">
<mx:Button label="Submit" click="fill()" width="100"/>
</mx:FormItem>
</mx:Form>
</mx:Canvas>
<mx:Panel label="DataGrid View" width="100%" height="100%">
<mx:DataGrid width="100%" height="100%" dataProvider="{listData}">
<mx:columns>
<mx:DataGridColumn dataField="firstName" headerText="First Name"/>
<mx:DataGridColumn dataField="lastName" headerText="Last Name"/>
<mx:DataGridColumn dataField="officePhone" headerText="Phone"/>
</mx:columns>
</mx:DataGrid>
<mx:Form backgroundColor="#FFFFFF">
<mx:FormItem label="Add New Employee">
<mx:Button label="Add..." click="{viewstack1.selectedIndex = 2}"
width="100"/>
</mx:FormItem>
</mx:Form>
</mx:Panel>
<mx:Canvas label="Add New Employee View" width="100%" height="100%">
<mx:Form horizontalCenter="0" verticalCenter="0"
backgroundColor="#FFFFFF">
<mx:FormItem label="First Name">
<mx:TextInput id="inputFirst"/>
</mx:FormItem>
<mx:FormItem label="Last Name">
<mx:TextInput id="inputLast"/>
</mx:FormItem>
<mx:FormItem label="Phone">
<mx:TextInput id="inputPhone"/>
</mx:FormItem>
<mx:FormItem label="Add Employee ">
<mx:Button label="Add" click="insertEmployee()" />
</mx:FormItem>
</mx:Form>
</mx:Canvas>
</mx:ViewStack>
</mx:Application>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
<mx:Script>
<![CDATA[
include "static-employees.as";
]]>
</mx:Script>
<mx:HTTPService
id="employeesService"
url="http://www.flexmonkeys.com/F3GSE/PartIII/CRUD/employees.xml"
resultFormat="e4x"
result="resultHandler(event)" />
<mx:ViewStack id="viewstack1" width="100%" height="100%" >
<mx:Canvas label="Form View" width="100%" height="100%">
<mx:Form horizontalCenter="0" verticalCenter="0" backgroundColor="#FFFFFF">
<mx:FormItem label="Query Employees ">
<mx:Button label="Submit" click="fill()" width="100"/>
</mx:FormItem>
</mx:Form>
</mx:Canvas>
<mx:Panel label="DataGrid View" width="100%" height="100%">
<mx:DataGrid width="100%" height="100%" dataProvider="{result.employee}">
<mx:columns>
<mx:DataGridColumn dataField="firstName" headerText="First Name"/>
<mx:DataGridColumn dataField="lastName" headerText="Last Name"/>
<mx:DataGridColumn dataField="officePhone" headerText="Phone"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:ViewStack>
</mx:Application>

16
04-employee-crud/Makefile Normal file
View File

@@ -0,0 +1,16 @@
MXMLC ?= mxmlc
all: CRUDDynamic.swf CRUDStatic.swf
CRUDDynamic.swf: CRUDDynamic.mxml
$(MXMLC) CRUDDynamic.mxml
CRUDStatic.swf: CRUDStatic.mxml
$(MXMLC) CRUDStatic.mxml
clean:
rm -f *.swf

View File

@@ -0,0 +1,43 @@
import mx.rpc.events.ResultEvent;
import mx.collections.XMLListCollection;
private var params:Object = new Object();
[Bindable]
private var listData:XMLListCollection;
public function resultHandler(event:ResultEvent):void {
var result:XML = XML(event.result);
var xmlList:XMLList = result.data.children();
listData = new XMLListCollection(xmlList);
}
public function insertItemHandler(event:ResultEvent):void {
fill();
}
public function fill():void{
employeesService.removeEventListener(ResultEvent.RESULT,insertItemHandler);
employeesService.addEventListener(ResultEvent.RESULT,resultHandler);
employeesService.method = "GET";
params['method'] = "FindAllEmployees";
employeesService.cancel();
employeesService.send(params);
viewstack1.selectedIndex=1;
}
public function insertEmployee():void{
employeesService.removeEventListener(ResultEvent.RESULT,resultHandler);
employeesService.addEventListener(ResultEvent.RESULT,insertItemHandler);
employeesService.method = "POST";
params = {"method": "InsertEmployee", "id": NaN, "firstName": inputFirst.text,
"lastName": inputLast.text, "officePhone": inputPhone.text};
employeesService.cancel();
employeesService.send(params);
clearInputFields();
}
private function clearInputFields():void{
inputFirst.text = "";
inputLast.text = "";
inputPhone.text = "";
}

View File

@@ -0,0 +1,20 @@
import mx.rpc.events.ResultEvent;
private var params:Object;
[Bindable]
private var result:XML;
private function initApp():void{
employeesService.cancel();
params= new Object();
}
public function resultHandler(event:ResultEvent):void {
result = XML( event.result);
}
public function fill():void{
viewstack1.selectedIndex=1;
employeesService.send(params);
}