flex2使用HTTPService得到xml資料繫結到datagrid

來源:互聯網
上載者:User
showlist.mxml:<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalGap="20" horizontalAlign="center" width="1024" fontFamily="宋體" fontSize="13">
<mx:HTTPService id="employeeSrv" showBusyCursor="true" url="employees.jsp">
<mx:request>
<deptId>{dept.selectedItem.data}</deptId>
</mx:request>
</mx:HTTPService>
<mx:TitleWindow title="HTTPService" horizontalAlign="center" height="299" width="662">
<mx:HBox horizontalAlign="center"><mx:Label text="選擇部門:"/>
<mx:ComboBox id="dept" width="150"><mx:dataProvider>
<mx:Array>
<mx:Object label="工程部" data="ENG"/>
<mx:Object label="產品管理" data="PM"/>
<mx:Object label="市場部" data="MKT"/>
</mx:Array>
</mx:dataProvider>
</mx:ComboBox><mx:Button label="查詢" click="employeeSrv.send();"/></mx:HBox>
 <mx:HBox width="100%" height="211">
  <mx:DataGrid dataProvider="{employeeSrv.lastResult.employees.employee}" width="100%" height="198">
  <mx:columns>
  <mx:Array>
  <mx:DataGridColumn dataField="name" headerText="姓名"/>
  <mx:DataGridColumn dataField="phone" headerText="電話"/>
  <mx:DataGridColumn dataField="email" headerText="郵件"/>
  </mx:Array>
  </mx:columns>
  </mx:DataGrid>
 </mx:HBox> </mx:TitleWindow></mx:Application> employees.jsp:<?xml version="1.0" encoding="utf-8"?>
<employees>
<%
String deptId=request.getParameter("deptId");
if (deptId.equals("ENG")) {
%>
<employee>
<name>喬王晨玉</name>
<phone>555-219-2270</phone>
<email>qzc1998@fictitious.com</email>
</employee>
<employee>
<name>Louis Freligh</name>
<phone>555-219-2100</phone>
<email>lfreligh@fictitious.com</email>
</employee>
<%
} else if (deptId.equals("PM")) {
%>
<employee>
<name>Ronnie Hodgman</name>
<phone>555-219-2030</phone>
<email>rhodgman@fictitious.com</email>
</employee>
<employee>
<name>Joanne Wall</name>
<phone>555-219-2012</phone>
<email>jwall@fictitious.com</email>
</employee>
<%
} else if (deptId.equals("MKT")) {
%>
<employee>
<name>Maurice Smith</name>
<phone>555-219-2012</phone>
<email>maurice@fictitious.com</email>
</employee>
<employee>
<name>Mary Jones</name>
<phone>555-219-2000</phone>
<email>mjones@fictitious.com</email>
</employee>
<%
}
%>
</employees>

 本文轉自: http://blog.chinaunix.net/u/11458/showart.php?id=282300

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.