- TbArea.java
- package com.zn.entity;
- import java.util.HashSet;
- import java.util.Set;
- /**
- * TbArea entity.
- *
- * @author MyEclipse Persistence Tools
- */
- public class TbArea implements java.io.Serializable {
- // Fields
- private String areaCode;
- private String areaName;
- private String parentAreaCode;
- private String root;
- private Short zone;
- private String navigateUrl;
- private Short areaType;
- private Set usercustems = new HashSet(0);
- // Constructors
- /** default constructor */
- public TbArea() {
- }
- /** full constructor */
- public TbArea(String areaName, String parentAreaCode, String root,
- Short zone, String navigateUrl, Short areaType, Set usercustems) {
- this.areaName = areaName;
- this.parentAreaCode = parentAreaCode;
- this.root = root;
- this.zone = zone;
- this.navigateUrl = navigateUrl;
- this.areaType = areaType;
- this.usercustems = usercustems;
- }
- // Property accessors
- public String getAreaCode() {
- return this.areaCode;
- }
- public void setAreaCode(String areaCode) {
- this.areaCode = areaCode;
- }
- public String getAreaName() {
- return this.areaName;
- }
- public void setAreaName(String areaName) {
- this.areaName = areaName;
- }
- public String getParentAreaCode() {
- return this.parentAreaCode;
- }
- public void setParentAreaCode(String parentAreaCode) {
- this.parentAreaCode = parentAreaCode;
- }
- public String getRoot() {
- return this.root;
- }
- public void setRoot(String root) {
- this.root = root;
- }
- public Short getZone() {
- return this.zone;
- }
- public void setZone(Short zone) {
- this.zone = zone;
- }
- public String getNavigateUrl() {
- return this.navigateUrl;
- }
- public void setNavigateUrl(String navigateUrl) {
- this.navigateUrl = navigateUrl;
- }
- public Short getAreaType() {
- return this.areaType;
- }
- public void setAreaType(Short areaType) {
- this.areaType = areaType;
- }
- public Set getUsercustems() {
- return this.usercustems;
- }
- public void setUsercustems(Set usercustems) {
- this.usercustems = usercustems;
- }
- }
TbArea.java
package com.zn.entity;
import java.util.HashSet;
import java.util.Set;
/**
* TbArea entity.
*
* @author MyEclipse Persistence Tools
*/
public class TbArea implements java.io.Serializable {
// Fields
private String areaCode;
private String areaName;
private String parentAreaCode;
private String root;
private Short zone;
private String navigateUrl;
private Short areaType;
private Set usercustems = new HashSet(0);
// Constructors
/** default constructor */
public TbArea() {
}
/** full constructor */
public TbArea(String areaName, String parentAreaCode, String root,
Short zone, String navigateUrl, Short areaType, Set usercustems) {
this.areaName = areaName;
this.parentAreaCode = parentAreaCode;
this.root = root;
this.zone = zone;
this.navigateUrl = navigateUrl;
this.areaType = areaType;
this.usercustems = usercustems;
}
// Property accessors
public String getAreaCode() {
return this.areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getAreaName() {
return this.areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public String getParentAreaCode() {
return this.parentAreaCode;
}
public void setParentAreaCode(String parentAreaCode) {
this.parentAreaCode = parentAreaCode;
}
public String getRoot() {
return this.root;
}
public void setRoot(String root) {
this.root = root;
}
public Short getZone() {
return this.zone;
}
public void setZone(Short zone) {
this.zone = zone;
}
public String getNavigateUrl() {
return this.navigateUrl;
}
public void setNavigateUrl(String navigateUrl) {
this.navigateUrl = navigateUrl;
}
public Short getAreaType() {
return this.areaType;
}
public void setAreaType(Short areaType) {
this.areaType = areaType;
}
public Set getUsercustems() {
return this.usercustems;
}
public void setUsercustems(Set usercustems) {
this.usercustems = usercustems;
}
}
TbArea.hbm.xml TbAreaDAO.java 就不贴出来数据访问是用的remoting-config.xml来控制的.
- <destination id="Service">
- <properties>
- <source>com.zn.service.BaseService</source>
- </properties>
- </destination>
<destination id="Service">
<properties>
<source>com.zn.service.BaseService</source>
</properties>
</destination>
- public class BaseService {
- /**
- * @param wqb
- */
- public BaseService(){}
- public String hello(){
- System.out.println("---------hello-----------------");
- return "hehe";
- }
- @SuppressWarnings("unchecked")
- public List<TbArea> getArea(String areaCode){
- TbAreaDAO ta=new TbAreaDAO();
- List<TbArea> arealist=new ArrayList<TbArea>();
- if(areaCode==null){
- arealist=ta.findByAreaType(1);
- }else{
- arealist=ta.findByParentAreaCode(areaCode);
- }
- return arealist;
- }
- }
public class BaseService {
/**
* @param wqb
*/
public BaseService(){}
public String hello(){
System.out.println("---------hello-----------------");
return "hehe";
}
@SuppressWarnings("unchecked")
public List<TbArea> getArea(String areaCode){
TbAreaDAO ta=new TbAreaDAO();
List<TbArea> arealist=new ArrayList<TbArea>();
if(areaCode==null){
arealist=ta.findByAreaType(1);
}else{
arealist=ta.findByParentAreaCode(areaCode);
}
return arealist;
}
}
再就到FLEX的页面了:
- <mx:Script>
- <![CDATA[
- import mx.rpc.events.FaultEvent;
- import mx.validators.ValidationResult;
- import mx.rpc.events.ResultEvent;
- import mx.collections.ArrayCollection;
- [Bindable]
- var chageArea:int=0;
- function init():void{
- service.getArea(null);
- }
- function getAreaResult(event:ResultEvent):void{
- if(chageArea==0){
- area1.dataProvider=event.result;
- }else if(chageArea==1){
- area2.dataProvider=event.result;
- }else{area3.dataProvider=event.result;}
- }
- function getAreaFault(event:FaultEvent):void{
- }
- function chageArea1():void{
- chageArea=1;
- area3=null;
- service.getArea(area1.selectedItem.areaCode);
- }
- function chageArea2():void{
- chageArea=2;
- service.getArea(area2.selectedItem.areaCode);
- }
- ]]>
- </mx:Script>
- <mx:RemoteObject id="service" destination="Service">
- <mx:method name="getArea" result="getAreaResult(event)" fault="getAreaFault(event)"/>
- </mx:RemoteObject>
- <mx:FormItem label="地区:" width="100%" fontSize="12">
- <mx:HBox width="100%">
- <mx:ComboBox fontSize="12" id="area1" width="75" labelField="areaName" change="chageArea1()"></mx:ComboBox>
- <mx:Label text="省" textAlign="center" width="20" height="100%" fontSize="14"/>
- <mx:ComboBox width="80" fontSize="12" id="area2" labelField="areaName" change="chageArea2()"></mx:ComboBox>
- <mx:Label text="市" width="20"/>
- <mx:ComboBox width="120" id="area3" labelField="areaName"></mx:ComboBox>
- </mx:HBox>
- </mx:FormItem>
<mx:Script> <![CDATA[ import mx.rpc.events.FaultEvent; import mx.validators.ValidationResult; import mx.rpc.events.ResultEvent; import mx.collections.ArrayCollection; [Bindable] var chageArea:int=0; function init():void{ service.getArea(null); } function getAreaResult(event:ResultEvent):void{ if(chageArea==0){ area1.dataProvider=event.result; }else if(chageArea==1){ area2.dataProvider=event.result; }else{area3.dataProvider=event.result;} } function getAreaFault(event:FaultEvent):void{ } function chageArea1():void{ chageArea=1; area3=null; service.getArea(area1.selectedItem.areaCode); } function chageArea2():void{ chageArea=2; service.getArea(area2.selectedItem.areaCode); } ]]> </mx:Script> <mx:RemoteObject id="service" destination="Service"> <mx:method name="getArea" result="getAreaResult(event)" fault="getAreaFault(event)"/> </mx:RemoteObject> <mx:FormItem label="地区:" width="100%" fontSize="12"> <mx:HBox width="100%"> <mx:ComboBox fontSize="12" id="area1" width="75" labelField="areaName" change="chageArea1()"></mx:ComboBox> <mx:Label text="省" textAlign="center" width="20" height="100%" fontSize="14"/> <mx:ComboBox width="80" fontSize="12" id="area2" labelField="areaName" change="chageArea2()"></mx:ComboBox> <mx:Label text="市" width="20"/> <mx:ComboBox width="120" id="area3" labelField="areaName"></mx:ComboBox> </mx:HBox> </mx:FormItem>
基本上重要实现代码都有了,先留在这也许下次用得上,呵呵!