1.首先在flex 初始化方法里面调用
private function initApp():void{
//通过调用action 获取部门的id
InfoSendJava.getdept(deptHandle);
}
InfoSendJava 类中的方法
这个方法是我写在一个通用的as 文件里面
static public function getdept(resultListener:Function):void {
httpService = new HTTPService();
httpService.useProxy = false;
httpService.method = "GET";
httpService.url = '/wcdb/taskManage/rwdj.TJ';
var parObj:Object = new Object();
parObj.method = 'getdeptId';
httpService.request = parObj;
httpService.addEventListener(FaultEvent.FAULT, alertPrompt);
httpService.addEventListener(ResultEvent.RESULT, resultListener);
httpService.send();
}
在看看action 是怎么写的
public ActionForward getdeptId(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
BaseUserBean userBean = (BaseUserBean) request.getSession().getAttribute(BaseConstants.UserBean);
String depId = userBean.getDeptId();
RwdjService rwService = (RwdjService) this.getBean("rwService");
TSysDepartment dept=rwService.getdeptname(depId);
response.getWriter().print("<?xml version=\"1.0\" encoding=\"utf-8\"?><deptid>\""+depId+"\"</deptid>" +"<deptlayer>"+dept.getLayer()+"</deptlayer><deptype>"+dept.getType()+"</deptype>");
return null;
}
在来看看flex页面是怎么获取数据的
注意这里的deptHandle 是和上面initApp方法里面的deptHandle 想对应的
private function deptHandle(event:ResultEvent):void{
var deptid:String=event.result.deptid;
deptlayer=event.result.deptlayer;
}