本人是从事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开发功能点吧. remoteObject used to get data from mysql database --> RemoteObject id="getDataObj" destination="ro" channelSet="{createChannelSet()}"> 注意 这里RemoteObject destination="ro" >要与 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通讯
发表评论
-
关于C#字符串截取的研究
2012-07-06 09:51 930对于网站程序员, ... -
通过正则表达式提取网页
2012-07-06 09:45 827转帖地址:http://www.cnblogs.com/g ... -
30分钟入门正则表达式
2012-07-06 09:37 494正则表达式30分钟入门教程 30分钟内让你明白正则表达式 ... -
金山卫士界面源码解读及界面库分离(1)
2012-07-06 09:30 866金山对其金山卫士进行了开源,目前已经公开了6个子项目。 ... -
js
2012-07-05 20:45 578欢迎大家光临,共同提高! ... -
Swing组件集合的事件处理(六)
2012-07-03 13:42 813请记住,Swing组件是构建在AWT库之上的,Swing组 ... -
使用blazeds实现flex和java交互
2012-07-02 10:23 651好久没研究flex 和 java 交互了,有个哥们问才拿起 ... -
Flex富文本编辑器
2012-07-02 10:23 1213近来在开发一个应用项目中,遇到一个富文本编辑框的问题,没想 ... -
全面认识Flex弹出窗口用法
2012-07-02 10:23 618在学习Flex的过程中 ... -
Flex中button按钮的例子
2012-07-02 10:23 646本源代码来源于flex完全自学手册 flex/spark ... -
android
2012-07-02 09:43 538... -
flex笔记--安装与项目建立
2012-07-01 09:42 514使用java做后台,采用Eclipse插件式安装 操 ... -
FLEX ComboBox绑定JAVA返回的数据源
2012-07-01 09:41 650万万没有想到会在一个小小的ComboBox上碰这么大钉子, ... -
Windows xp和ubuntu 9.10双系统,重装windows后,mbr被覆盖,grub不能启动的解决方法
2012-06-30 17:57 980Windows xp和ubuntu 9.10双系统,重 ... -
安装Oracle9I出现"加载数据库时出错:areasQueries错误"的解决方法
2012-06-30 17:57 647安装Oracle9I出现"加载数据库时出错:a ... -
Visual Studio 2008 SP1 补丁安装时发生严重错误-安装失败-解决方法整合版!-分享
2012-06-30 17:57 2231Visual Studio 2008 SP1 ... -
ppc 模拟器的安装、配置,以及一些常见问题及解决方法
2012-06-30 17:57 10981、安装前提条件: 安装了Visual Stdio ... -
sql server 2008 常见安装错误解决方法
2012-06-30 17:57 9341、sql server 2008 提示"重新启 ...
相关推荐
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数据交互_方式