Flex/Java Web 应用程序的外部化客户端 ChannelSet 配置
我正在寻找一种方法,允许我(以某种方式)动态地将服务器名称、服务器端口和 Web 上下文传递到我的 Flex 客户端,以便它可以创建一个 ChannelSet 供其 RemoteObjects 使用。当然,我的 Java 服务器端代码可以轻松使用这三个属性,因此我只需要一种将它们传递给客户端的方法。
默认情况下,Adobe 表示 您应该根据服务器配置文件“services-config.xml”编译 Flex 应用程序。 Spring 说 应该避免(我同意)。
一种流行方法< /a> 是使用Flex的http服务下载XML配置文件。我喜欢这个想法,但我不想硬编码 XML 文件并将其保存在我的 WAR 文件中。有没有办法从 Java 代码动态生成它?
我的另一个想法是以某种方式使用 flashvars 将属性从包含的 HTML 页面传递到 SWF 文件。但同样,我不想将它们硬编码到 HTML 页面中。有没有办法(也许用Javascript?)在页面加载时动态设置这些值?
I am looking for an approach that will allow me to (somehow) dynamically pass the server name, server port, and web context to my Flex client so it can create a ChannelSet for it's RemoteObjects to use. These three properties are, of course, readily available to my Java server-side code so I just need a way to get them to the client.
By default, Adobe says you should compile your Flex application against the server configuration file "services-config.xml". This is a highly inflexible practice that Spring says should be avoided (I agree).
One popular approach is to use Flex's http service to download an XML configuration file. I like this idea, but I don't want to hard-code an XML file and keep it inside my WAR file. Is there a way to dynamically generate this from Java code?
Another idea I had is to somehow use flashvars to pass the properties in from the containing HTML page to the SWF file. But again, I don't want to hard code them into the HTML page. Is there a way (maybe with Javascript?) to dynamically set the value of these when the page loads?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我就是这样做的。我希望您会发现它很有用:
因此,正如您所看到的,您需要提供的唯一内容是目标 - 必须在服务器端 XML 和 contextRoot 中配置 - 作为 flashVar 传递。在我的例子中(通过 JSP)作为 flashVar 传递看起来像这样:
This is how I do it. I hope you'll find it useful:
So as you can see the only things you need to provide are destination - which must be configured in server side XML and contextRoot - passed as flashVar. Passing as flashVar in my case (through JSP) looks like this: