`
huangshenji
  • 浏览: 9774 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

Flex Combox 实现3级联动

    博客分类:
  • Java
阅读更多
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" title="Add Store" fontWeight="bold" fontSize="13" backgroundColor="#9AEDFF" backgroundAlpha="0.2" borderColor="#7CFFF4" themeColor="#97D7FF">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
private var cityList:ArrayCollection ;
[Bindable]
private var countyList:ArrayCollection ;

public function changeHandlerProvice():void{
countyList=null;
var remoteCity:RemoteObject = new RemoteObject("cityDao");
remoteCity.getCityListByPid(this.provice.selectedItem.id);
remoteCity.addEventListener(ResultEvent.RESULT,handleGetCitySuccess);
remoteCity.addEventListener(FaultEvent.FAULT,handleGetDataError);
            }
            public function changeHandlerCity():void{
var remoteCounty:RemoteObject = new RemoteObject("countyDao");
remoteCounty.getCountyListByCid(this.city.selectedItem.id);
remoteCounty.addEventListener(ResultEvent.RESULT,handleGetCountySuccess);
remoteCounty.addEventListener(FaultEvent.FAULT,handleGetDataError);
            }
            private function handleGetCitySuccess(event:ResultEvent):void{
cityList= event.result as ArrayCollection;
if(cityList!=null){
city.dataProvider = cityList;
}
}
private function handleGetCountySuccess(event:ResultEvent):void{
countyList= event.result as ArrayCollection;
if(countyList!=null){
county.dataProvider = countyList;
}
}
private function handleGetDataError(event:FaultEvent):void{
Alert.show("访问远程对象错误...","信息提示");
}

private function initCity():void{
var remoteCity:RemoteObject = new RemoteObject("cityDao");
remoteCity.getCityListByPid(1);
remoteCity.addEventListener(ResultEvent.RESULT,handleGetCitySuccess);
remoteCity.addEventListener(FaultEvent.FAULT,handleGetDataError);
var remoteCounty:RemoteObject = new RemoteObject("countyDao");
remoteCounty.getCountyListByCid(1);
remoteCounty.addEventListener(ResultEvent.RESULT,handleGetCountySuccess);
remoteCounty.addEventListener(FaultEvent.FAULT,handleGetDataError);
}

]]>
</mx:Script>
<!--<mx:XML id="areaXml" source="area.xml"/>
   <mx:RemoteObject id="srv2" destination="cityDao"/>
-->
<mx:RemoteObject id="pDao" destination="proviceDao"/>

<mx:Form x="10" y="10" width="100%" height="100%">
<mx:FormItem label="Store Name:" width="100%">
<mx:TextInput width="80%"/>
</mx:FormItem>
<mx:FormItem label="Area" id="area"   direction="horizontal">
      <mx:ComboBox creationComplete="pDao.getAllProviceList()"  id="provice" width="100" dataProvider="{pDao.getAllProviceList.lastResult}" labelField="provicename"   change="changeHandlerProvice()"/>
      <mx:ComboBox  id="city" creationComplete="initCity()" width="100" dataProvider="{cityList}" labelField="cityname"  change="changeHandlerCity()"/>
<mx:ComboBox width="100" id="county" dataProvider="{countyList}" labelField="countyname"/>
<mx:TextInput width="117" id="town"/>
</mx:FormItem>

</mx:Form>

</mx:Panel>

remote-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService">

<adapters>
<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true" />
</adapters>

<default-channels>
<channel ref="my-amf" />
</default-channels>

<destination id="storeDao">
<properties>
<factory>spring</factory>
<source>storeDao</source>
</properties>
</destination>

<destination id="proviceDao">
<properties>
<factory>spring</factory>
<source>proviceDao</source>
</properties>
</destination>

<destination id="cityDao">
<properties>
<factory>spring</factory>
<source>cityDao</source>
</properties>
</destination>

<destination id="countyDao">
<properties>
<factory>spring</factory>
<source>countyDao</source>
</properties>
</destination>
</service>

分享到:
评论
1 楼 lqw8668 2009-08-20  
  

相关推荐

Global site tag (gtag.js) - Google Analytics