Flex中VO在Java端用Map接收
??????????????????????????????? Flex中VO在Java端用Map接收
Flex端: Mxml页面的添加和修改方法: private function addUser():void { ? _theUModel.allUserInfo = new UserVO();//_theUModel是UserModel的对象 _theUModel.allUserInfo.UID = 0; _theUModel.allUserInfo.UName = this.txt_UName.text ; _theUModel.allUserInfo.UPwd = this.txt_UPwd.text ; _theUModel.allUserInfo.ULevel = this.cbbx_ULevel.selectedItem.data ; _theUModel.allUserInfo.UType = this.cbbx_UType.selectedItem.data? ; ???????????????????????????????????????????????????????????????????????????? // cbbx_ULevel为页面的下拉选ID if(this.rio_Boy.selected == true) {???????? //rio_Boy为页面的单选按钮ID _theUModel.allUserInfo.USex = 0 ; } else { _theUModel.allUserInfo.USex = 1 ; } ? if(this.cbx_UserState.selected == true) {//cbx_UserState为页面的多选按钮ID _theUModel.allUserInfo.UState = 1 ; } else { _theUModel.allUserInfo.UState = 0 ; } _theUserCtrl.addOrUpdUser(_theUModel.allUserInfo); } ? private function updUser():void { ? _theUModel.allUserInfo = new UserVO(); _theUModel.allUserInfo.UID = _theUModel.selectedUser.UID; _theUModel.allUserInfo.UName = this.txt_UName.text ; _theUModel.allUserInfo.UPwd = this.txt_UPwd.text ; _theUModel.allUserInfo.ULevel = this.cbbx_ULevel.selectedItem.data ; _theUModel.allUserInfo.UType = this.cbbx_UType.selectedItem.data? ; ? if(this.rio_Boy.selected == true) {?? //rio_Boy为页面的单选按钮ID _theUModel.allUserInfo.USex = 0 ; } else { _theUModel.allUserInfo.USex = 1 ; } ? if(this.cbx_UserState.selected == true) {? //cbx_UserState为页面的多选按钮ID _theUModel.allUserInfo.UState = 1 ; } else { _theUModel.allUserInfo.UState = 0 ; } _theUserCtrl.addOrUpdUser(_theUModel.allUserInfo); ?????? //_theUserCtrl为UserControl.as的对象 } ? UserModel.as文件: package model { import flash.events.EventDispatcher; import mx.collections.ArrayCollection; import vo.UserVO; ? [Bindable] public class UserModel extends EventDispatcher { private static var _instance:UserModel; ? public static function getInstance():UserModel{ if(_instance==null){ _instance=new UserModel(); } return _instance; } public var allUserInfo:UserVO ; } } ? UserVO.as文件: package vo { Bindable] public class UserVO { public var UID:int; public var UName:String; public var UPwd:String; public var USex:int; public var ULevel:int; public var UState:int; public function fill(obj:Object):void{ for(var i:* in obj){ this[i]=obj[i]; } } } ? ? Java端的方法: public boolean addOrUpdUser(Map map) { ? int UID = Integer.parseInt(map.get("UID").toString()) ; String UName = map.get("UName").toString().trim();??? String UPwd = map.get("UPwd").toString().trim(); int USex = Integer.parseInt(map.get("USex").toString()); int ULevel = Integer.parseInt(map.get("ULevel").toString()); int UState = Integer.parseInt(map.get("UState").toString()); DBManager dbMng = new DBManager(); boolean sign = false; ? String sql = ""; if(UID == 0) { sql = "insert ……" ; } else { sql = "update ……" ; } try { sign = dbMng.Execute(sql,true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return sign ; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |