WEB开发网
开发学院图形图像Flash 跟我StepByStep学FLEX教程------Demo13之Fl... 阅读

跟我StepByStep学FLEX教程------Demo13之Flex访问数据库

 2009-09-09 00:00:00 来源:WEB开发网   
核心提示: 3、在applicationContext.xml中配置bean,如下:<bean id="productDAOBean" class="com.samples.spring.store.SimpleProductDAO"> <prope

3、在applicationContext.xml中配置bean,如下:

<bean id="productDAOBean" class="com.samples.spring.store.SimpleProductDAO">
        <property name="dataSource" ref="dataSource"/>
    </bean>

4、在remoting-config.xml中配置向Flex客户端公开的bean,如下:

<destination id="productService">
     <properties>
         <factory>spring</factory>
         <source>productDAOBean</source>
     </properties>
 </destination>

5、接下来就是Flex客户端的代码了

HelloFlexPro.mxml(主文件)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" creationComplete="srv.findAll()"> 
 <mx:Script>
 <![CDATA[
  import mx.rpc.events.ResultEvent;
  import mx.controls.Alert;
  import mx.rpc.events.FaultEvent;
   
  private function findAllFaultHandler(event:FaultEvent):void
  {
   Alert.show(event.fault.faultString, "Error");
  }
 ]]>
 </mx:Script>
 <mx:RemoteObject id="srv" destination="productService">
  <mx:method name="findAll" fault="findAllFaultHandler(event)"/>
 </mx:RemoteObject>
 
 <mx:HDividedBox width="100%" height="100%">

  <mx:Panel title="Inventory Management" width="100%" height="100%">
   <mx:DataGrid id="list" width="100%" height="100%" dataProvider="{srv.findAll.lastResult}">
    <mx:columns>
     <mx:DataGridColumn dataField="name" headerText="Name"/>
     <mx:DataGridColumn dataField="category" headerText="Name"/>
     <mx:DataGridColumn dataField="qtyInStock" headerText="In Stock"/>
    </mx:columns>
   </mx:DataGrid>
  </mx:Panel>
  
  <ProductForm product="{Product(list.selectedItem)}"/>

 </mx:HDividedBox>
</mx:Application>

上一页  1 2 3 4 5  下一页

Tags:StepByStep FLEX 教程

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接