a grand renaming so that the most significant portion of the name comes first
This commit is contained in:
89
flex-practice/custom-03d3-lists/ListApp.as
Normal file
89
flex-practice/custom-03d3-lists/ListApp.as
Normal file
@@ -0,0 +1,89 @@
|
||||
package
|
||||
{
|
||||
import flash.events.MouseEvent;
|
||||
import mx.collections.ArrayCollection;
|
||||
import mx.controls.Alert;
|
||||
import mx.controls.Button;
|
||||
import mx.controls.List;
|
||||
import mx.controls.Text;
|
||||
import mx.core.Application;
|
||||
import mx.events.ListEvent;
|
||||
import mx.rpc.events.FaultEvent;
|
||||
import mx.rpc.events.ResultEvent;
|
||||
import mx.rpc.http.HTTPService;
|
||||
|
||||
public class ListApp extends Application
|
||||
{
|
||||
[Bindable]
|
||||
public var employeeList:ArrayCollection = new ArrayCollection();
|
||||
public var employeesService:HTTPService;
|
||||
public var textMessage:Text;
|
||||
public var mylist:List;
|
||||
public var mybutton:Button;
|
||||
|
||||
public static const employeesServiceUrl:String =
|
||||
"http://localhost:18080/employees.xml";
|
||||
|
||||
public function appComplete():void
|
||||
{
|
||||
_initButtonControl();
|
||||
_initListControl();
|
||||
_initEmployeesService();
|
||||
trace(this + " initialized!");
|
||||
}
|
||||
|
||||
private function _initButtonControl():void
|
||||
{
|
||||
trace(this + "._initButtonControl()");
|
||||
mybutton.addEventListener(MouseEvent.CLICK, requestEmployees);
|
||||
}
|
||||
|
||||
private function _initListControl():void
|
||||
{
|
||||
trace(this + "._initListControl()");
|
||||
mylist.addEventListener(ListEvent.ITEM_CLICK, showMessage);
|
||||
trace(this + ".mylist.dataProvider = " + mylist.dataProvider);
|
||||
}
|
||||
|
||||
private function _initEmployeesService():void
|
||||
{
|
||||
trace(this + "._initEmployeesService()");
|
||||
employeesService = new HTTPService();
|
||||
employeesService.url = employeesServiceUrl;
|
||||
employeesService.method = "GET";
|
||||
employeesService.resultFormat = "object";
|
||||
employeesService.addEventListener("result", resultHandler);
|
||||
employeesService.addEventListener("fault", faultHandler);
|
||||
}
|
||||
|
||||
public function requestEmployees(event:Event):void
|
||||
{
|
||||
trace(this + ".requestEmployees(" + event + ")");
|
||||
employeesService.send();
|
||||
}
|
||||
|
||||
public function resultHandler(event:ResultEvent):void
|
||||
{
|
||||
trace(this + ".resultHandler(" + event + ")");
|
||||
trace(this + " event.result = " + event.result);
|
||||
trace(this + " event.headers = " + event.headers);
|
||||
trace(this + " event.statusCode = " + event.statusCode);
|
||||
trace(this + " event.result.employees = " + event.result.employees);
|
||||
employeeList = event.result.employees.employee as ArrayCollection;
|
||||
// mylist.dataProvider = employeeList;
|
||||
trace(this + ".employeeList = " + employeeList);
|
||||
}
|
||||
|
||||
public function faultHandler(event:FaultEvent):void {
|
||||
var faultstring:String = event.fault.faultString;
|
||||
Alert.show(faultstring);
|
||||
}
|
||||
|
||||
public function showMessage(event:Event):void
|
||||
{
|
||||
textMessage.text = "You selected: " +
|
||||
event.currentTarget.selectedItem.firstName + ' ' +
|
||||
event.currentTarget.selectedItem.lastName;
|
||||
}
|
||||
}
|
||||
}
|
10
flex-practice/custom-03d3-lists/ListControl.mxml
Normal file
10
flex-practice/custom-03d3-lists/ListControl.mxml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<loc:ListApp xmlns:loc="*"
|
||||
xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
applicationComplete="appComplete();">
|
||||
<mx:Style source="listapp.css" />
|
||||
<mx:Button id="mybutton" label="Return Employees" />
|
||||
<mx:List id="mylist" styleName="basic-list"
|
||||
dataProvider="{employeeList}" labelField="firstName" />
|
||||
<mx:Text id="textMessage" styleName="basic-text" />
|
||||
</loc:ListApp>
|
66
flex-practice/custom-03d3-lists/employees.py
Normal file
66
flex-practice/custom-03d3-lists/employees.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import sys
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
|
||||
EMPLOYEES_XML = """\
|
||||
<employees>
|
||||
<employee id="101" code="233">
|
||||
<firstName>Bob</firstName>
|
||||
<lastName>Costas</lastName>
|
||||
</employee>
|
||||
<employee id="102" code="233">
|
||||
<firstName>Bob</firstName>
|
||||
<lastName>Sagat</lastName>
|
||||
</employee>
|
||||
<employee id="103" code="233">
|
||||
<firstName>Harbor</firstName>
|
||||
<lastName>Oaks</lastName>
|
||||
</employee>
|
||||
<employee id="104" code="233">
|
||||
<firstName>Oak</firstName>
|
||||
<lastName>Barrel</lastName>
|
||||
</employee>
|
||||
<employee id="105" code="233">
|
||||
<firstName>Sag</firstName>
|
||||
<lastName>Harbor</lastName>
|
||||
</employee>
|
||||
</employees>
|
||||
"""
|
||||
EMPLOYEES_XML_LEN = str(len(EMPLOYEES_XML))
|
||||
CROSSDOMAIN_XML = """\
|
||||
<cross-domain-policy>
|
||||
<allow-access-from domain="*"/>
|
||||
</cross-domain-policy>
|
||||
"""
|
||||
CROSSDOMAIN_XML_LEN = str(len(CROSSDOMAIN_XML))
|
||||
|
||||
|
||||
def main(sysargs=sys.argv[:]):
|
||||
server = make_server('0.0.0.0', 18080, employees_app)
|
||||
server.serve_forever()
|
||||
return 0
|
||||
|
||||
|
||||
def employees_app(environ, start_response):
|
||||
path_info = environ.get('PATH_INFO', '/').strip(' /')
|
||||
if path_info == 'employees.xml':
|
||||
start_response('200 OK', [
|
||||
('content-type', 'text/xml'),
|
||||
('content-length', EMPLOYEES_XML_LEN),
|
||||
])
|
||||
return [EMPLOYEES_XML]
|
||||
elif path_info == 'crossdomain.xml':
|
||||
start_response('200 OK', [
|
||||
('content-type', 'text/xml'),
|
||||
('content-length', CROSSDOMAIN_XML_LEN),
|
||||
])
|
||||
return [CROSSDOMAIN_XML]
|
||||
else:
|
||||
start_response('404 Not Found', [('content-type', 'text/plain')])
|
||||
return ['sorry charlie']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
# vim:filetype=python
|
16
flex-practice/custom-03d3-lists/listapp.css
Normal file
16
flex-practice/custom-03d3-lists/listapp.css
Normal file
@@ -0,0 +1,16 @@
|
||||
ListApp {
|
||||
backgroundColor: #ffffff;
|
||||
backgroundAlpha: 0;
|
||||
horizontalAlign: left;
|
||||
verticalGap: 15;
|
||||
horizontalGap: 15;
|
||||
}
|
||||
|
||||
.basic-list {
|
||||
width: 200;
|
||||
height: 200;
|
||||
}
|
||||
|
||||
.basic-text {
|
||||
paddingTop: 20;
|
||||
}
|
Reference in New Issue
Block a user