您的位置:首页 > 移动开发 > Objective-C

flex动态设置RemoteObject endpoing

2014-11-27 20:56 417 查看
在flex开发中经常碰到用户部署项目时跟开发时的项目名称不一样.但flex是编译时生成的endpoing,换个名称部署项目flex就不能访问服务.

解决办法:

使用jsp获取当前项目名及路径.使用flex调用js的方法,获取项目的路径及名称.修改endpoint

具体源码如下:

Flex:

<s:RemoteObject id="IndexServicesController" destination="IndexServicesController" fault="httpServiceFault(event)"
endpoint="{endpoint}/messagebroker/amf">
<s:method name="getSysMenu" result="getSysMenuResultHandler(event)" />
</s:RemoteObject>
override protected function createChildren():void {
if(ExternalInterface.available){
endpoint = ExternalInterface.call("getEndopint");
}
super.createChildren();
}

[Bindable]
private var endpoint:String = "";


JSP:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script type="text/javascript">

function getEndopint()
{
return "<%=basePath%>";
}
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: