- 浏览: 43506 次
- 性别:
- 来自: 北京
最新评论
本人是从事BS架构应用开发的,现在发现客户越来越关注用户的互动体验,视觉上的冲击 界面与提示友好 portlet 百花齐放
基于各方面原因,现在开始关注flex技术.没说的最终还是要与实际应用结合来使用的.如何让flex开发的.swf与java进行数据交互?了解到flex是用amf与java进行数据交互的,按照网上搜出来的相关文档进行配置
首先下载BlazeDS包 解压后
将lib下的jar包copy到自己建立好的web应用的lib下,将flex文件夹直接copy到/WEB-INF下(包括4个xml文件),在web.xml里加入 MessageBrokerServlet MessageBrokerServlet flex.messaging.MessageBrokerServlet contextConfigLocation /WEB-INF/flex/services-config.xml 1 struts2 /sevlet/* MessageBrokerServlet /messagebroker/* 注意 由于我用的是struts2+spring2.5+Hibernate3.3 开始由于在配置struts2的/*使我的/messagebroker/*请求总接收不到 郁闷了好半天 最后将应用中所有的请求加了一级路径 才分开
配置好后访问http://{server.name}:{server.port}/{context.root}/ messagebroker/amf如果能够访问 那么应用一级就配置好了
下面开始用flex开发功能点吧. 注意 这里要与 remoting-config.xml中的id 对应 ro spring 如果你不是使用spring 那么就将标签去掉在中写类的全路径 如果用spring进行管理的话 要在service-config.xml中
加入 中间的实现类可以自己写
代码如下 package com.chinasofti.comm.utils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.NoSuchBeanDefini tionException; import org.springframework.context.ApplicationContext; import org.springframework.web.context.support.WebApplica tionContextUtils; import flex.messaging.FactoryInstance; import flex.messaging.FlexFactory; import flex.messaging.config.ConfigMap; import flex.messaging.services.ServiceException; public class SpringFactory implements FlexFactory { private static final String SOURCE = "source"; /** * This method can be used to initialize the factory itself. It is called * with configuration parameters from the factory tag which defines the id * of the factory. */ public void initialize(String id, ConfigMap configMap) { } /** * This method is called when we initialize the definition of an instance * which will be looked up by this factory. It should validate that the * properties supplied are valid to define an instance. Any valid properties * used for this configuration must be accessed to avoid warnings about * unused configuration elements. If your factory is only used for * application scoped components, this method can simply return a factory * instance which delegates the creation of the component to the * FactoryInstance's lookup method. */ public FactoryInstance createFactoryInstance(String id, ConfigMap properties) { SpringFactoryInstance instance = new SpringFactoryInstance(this, id, properties); instance.setSource(properties.getPropertyAsString( SOURCE, instance .getId())); return instance; } // end method createFactoryInstance() /** * Returns the instance specified by the source and properties arguments. * For the factory, this may mean constructing a new instance, optionally * registering it in some other name space such as the session or JNDI, and * then returning it or it may mean creating a new instance and returning * it. This method is called for each request to operate on the given item * by the system so it should be relatively efficient. * * If your factory does not support the scope property, it report an error * if scope is supplied in the properties for this instance. * */ public Object lookup(FactoryInstance inst) { SpringFactoryInstance factoryInstance = (SpringFactoryInstance) inst; return factoryInstance.lookup(); } static class SpringFactoryInstance extends FactoryInstance { SpringFactoryInstance(SpringFactory factory, String id, ConfigMap properties) { super(factory, id, properties); } public String toString() { return "SpringFactory instance for id=" + getId() + " source=" + getSource() + " scope=" + getScope(); } public Object lookup() { ApplicationContext appContext = WebApplicationContextUtils .getWebApplicationContext(flex.messaging.FlexConte xt .getServletConfig().getServletContext()); String beanName = getSource(); try { return appContext.getBean(beanName); } catch (NoSuchBeanDefinitionException nexc) { ServiceException e = new ServiceException(); String msg = "Spring service named '" + beanName + "' does not exist."; e.setMessage(msg); e.setRootCause(nexc); e.setDetails(msg); e.setCode("Server.Processing"); throw e; } catch (BeansException bexc) { ServiceException e = new ServiceException(); String msg = "Unable to create Spring service named '" + beanName + "' "; e.setMessage(msg); e.setRootCause(bexc); e.setDetails(msg); e.setCode("Server.Processing"); throw e; } } } } 好了 以上就是flex与java的应用整合的实例
关注点在是否能访问http://{server.name}:{server.port}/{context.root}/ messagebroker/amf
呵呵 也就是你的swf是否能与java通讯
发表评论
-
JavaScript 操作字符串的一些方法
2012-07-06 09:51 327虽然 JavaScript 有很 ... -
Coldfusion的正则表达式替换。
2012-07-06 09:45 381Coldfusion的正则表达式不是很强大,所以一直没有怎 ... -
常用正则表达式(?i)忽略字母的大小写!
2012-07-06 09:37 12971。^\d+$ //匹配非负 ... -
CAT动画
2012-07-06 09:30 7611.创建CAT骨骼 创建--辅助对象-CAT Obje ... -
Ajax添加数据与删除篇
2012-07-05 20:45 923作者:康董 我很开 ... -
RichFaces树组件的用法
2012-07-03 13:43 595RichFaces树组件的用法 原创:版权所有chsz ... -
Flex加载flash_as3_swf,并响应其中的按钮事件
2012-07-02 10:46 625注:flash_as3_swf里的源码里有一个btn_fu ... -
Flex 3 图片移动 缩放
2012-07-02 10:46 451第一个是 mx.effects.Move 移动 第二 ... -
Flex中DataGrid绑定(嵌入)ComboBox
2012-07-02 10:46 608width="578 ... -
Flex 与 c# socket 完整实例:聊天室
2012-07-02 10:46 835===客户端=== 需要建一个公用的as class ... -
SWFAddress实现Flex深度链接(不同模块具有不同的URL)
2012-07-01 00:24 546众所周知,Flex明显区别于传统B/S开发模式的特性中,有 ... -
将 Flex 3 的应用程序迁移到 Flex 4 ―第 1 部分:将 Flex 3 Dashboard 应用程序导入 Flash Builder 4
2012-07-01 00:24 587本系列一共 4 个部 ... -
flex基础概念
2012-07-01 00:24 495SDK(Software Development Kit, ... -
Flex 和 Ogre
2012-07-01 00:24 581最近和赖爷聊了聊,于是决定看看网页游戏方面的资料。在赖爷的 ...
相关推荐
flex使用 RemoteObject 与java进行json格式的数据交互
前台FLex工程(单独工程Cairngorm)使用Cairngorm框架与后台java工程(FLexToJava)进行数据交互。功能点: ①flex提交表单保存到数据库; ②flex向后台请求,后台返回List集合,flex将集合填充到combox 附带:...
flex与java通过BlazeDs进行交互
Flex 和 Java的交互实例.非常值得参考
Flex与java和数据库交互的完美文档
实现Flex和Java交互.rar 实现flex与java的交互问题
这里有flex的学习资料 很有价值的,还有flex和java交互的资料 都是word格式的 看了就能懂
Flex和java交互搭建,新手可以用来练手,简单易懂
Flex与java交换数据 Flex数据交换 Flex与java交换数据教程。
Flex与Java使用Json数据交互所需要的JAR包
这是本人做的Flex4 通过HttpService与Java进行交互项目,本人测试通过。本人在此声明运行环境为:MyEclipse 8.5,JDK 6,Tomcate 6,Flex 4. 本人已经将Flex4整合到Myeclipse 8.5中去了,所以这个项目是在MyEclipse ...
Flex与Java实现通信,Flex与Java实现通信,Flex与Java实现通信
Flex和java交互的示例代码,给出的Flex部分:前端界面和vo,后端Java部分,以及配置部分。注意:我直接用的JDBC连接MySql,且只做了数据显示,没有增修改删除。
拿来直接就用的flex 和java交互的入门实例,简单的不能再简单,包括所有的jar包
最简单的BlazeDS实现flex与java通信..无积分下载...最简单的BlazeDS实现flex与java通信..无积分下载...最简单的BlazeDS实现flex与java通信..无积分下载...最简单的BlazeDS实现flex与java通信..无积分下载...最简单的...
这是一个关于flex4与后台数据进行交互的内容,个人感觉还不错的。
Flex+BlazeDB+mysql实现数据交互.docx
Flex与Java通过实体传递数据
flex与PHP后台数据交互的学习小记,Flex与后台交互的方法
flex数据交互_方式