学习flex 初步实现与java进行数据交互
2010年06月03日
本人是从事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通讯
发表评论
-
判断是否是正确日期字符串的函数
2012-07-06 09:52 1138个人写的一个判断是否是正确日期字符串的函数, 请大家点评 ... -
PyQt4--QLineEdit内引入正则表达式
2012-07-06 09:46 1512from PyQt4.QtCore import * ... -
杂记之通过style样式xml定义规范组件属性
2012-07-03 13:44 978效果图 main.xml 组件进行关联 --& ... -
Flex 不支持GIF的解决方法
2012-07-02 13:12 893GIF图片,加载到Image后,不能动起来,需要把 gif ... -
使用Flex和Actionscript开发Flash游戏――碰撞检测
2012-07-02 13:12 578这一部分,我们加 ... -
完美解决Panel设置了borderSkin后内容体与标题栏重叠的问题
2012-07-02 13:12 786如果您做过Flex皮肤 ... -
flex 实现的多点切割+mask蒙版+自动识别非透明区域+自适应图片大小
2012-07-02 13:12 1455先上代码: 1){ ... -
flex 界面改进
2012-07-02 13:12 573f 代码如下: ... -
flex 实现的多点切割+mask蒙版+自动识别非透明区域+自适应图片大小
2012-07-01 10:44 1208先上代码: Arr ... -
Flex DataGrid单元格背景色 单元格字体颜色控制
2012-07-01 10:43 1094前阵子在做Flex网页时,关于单元格字体颜色这方面纠结了好 ... -
flex 读取配置文件 与PHP交互 圆饼图
2012-07-01 10:43 629FLEX文件 teacherevalute.mxml ... -
flex 界面改进
2012-07-01 10:43 650f 代码如下: Arr ... -
flex招式八:flex共享对象ShareObject
2012-07-01 10:43 774flex的共享对象ShareO ... -
Flex是咋回事之三 谁用谁知道
2012-06-30 17:07 613Flex是咋回事之三 谁用谁知道 2010年09月21日 ... -
java与flex通信
2012-06-30 17:07 598java与flex通信 2010年10月22日 一、准备 ... -
如何使用Maven 3.0, Flex Mojos 4.0和Flex 4.5构建一个简单的SWF程序
2012-06-30 17:07 1281如何使用Maven 3.0, Flex Mojos 4.0和F ... -
Flex数据绑定陷阱(二)
2012-06-30 17:07 653Flex数据绑定陷阱(二) 2010年08月10日 尝试 ...
相关推荐
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数据交互_方式