- 浏览: 133351 次
- 性别:
- 来自: 北京
文章分类
最新评论
做个备忘。
Flex中的Feature.as映射自Java中的Feature.java 。
Flex中的Feature类需要绑定Java中的Feature类。
package hashmap { [Bindable] [RemoteClass(alias="hashmap.Feature")] public class Feature { public var FeatureID:String; public var FeatureName:String; public var FeatureImageURL:String; public var FeatureWidth:String; public var FeatureHeight:String; public function Feature(){ } // public function Feature(ID:String, Name:String, ImageURL:String, Width:String, Height:String){ // this.FeatureID = ID; // this.FeatureName = Name; // this.FeatureImageURL = ImageURL; // this.FeatureWidth = Width; // this.FeatureHeight = Height; // } public function getFeatureID():String{ return FeatureID; } public function setFeatureID(featureID:String):void{ this.FeatureID = featureID; } public function getFeatureName():String{ return FeatureName; } public function setFeatureName(featureName:String):void{ this.FeatureName = featureName; } public function getFeatureImageURL():String{ return FeatureImageURL; } public function setFeatureImageURL(featureImageURL:String):void{ this.FeatureImageURL = featureImageURL; } public function getFeatureWidth():String{ return FeatureWidth; } public function setFeatureWidth(featureWidth:String):void{ this.FeatureWidth = featureWidth; } public function getFeatureHeight():String{ return FeatureHeight; } public function setFeatureHeight(featureHeight:String):void{ this.FeatureHeight = featureHeight; } } }
Java中的Feature类需要实现java.io.Serializable
package hashmap; public class Feature implements java.io.Serializable { public String FeatureID; public String FeatureName; public String FeatureImageURL; public String FeatureWidth; public String FeatureHeight; public Feature(){ } public Feature(String ID, String Name, String ImageURL, String Width, String Height){ this.FeatureID = ID; this.FeatureName = Name; this.FeatureImageURL = ImageURL; this.FeatureWidth = Width; this.FeatureHeight = Height; } public String getFeatureID() { return FeatureID; } public void setFeatureID(String featureID) { FeatureID = featureID; } public String getFeatureName() { return FeatureName; } public void setFeatureName(String featureName) { FeatureName = featureName; } public String getFeatureImageURL() { return FeatureImageURL; } public void setFeatureImageURL(String featureImageURL) { FeatureImageURL = featureImageURL; } public String getFeatureWidth() { return FeatureWidth; } public void setFeatureWidth(String featureWidth) { FeatureWidth = featureWidth; } public String getFeatureHeight() { return FeatureHeight; } public void setFeatureHeight(String featureHeight) { FeatureHeight = featureHeight; } }
Java中的方法,返回HashMap:
package hashmap; import java.util.*; public class TestHashMap { public HashMap<String, List<Feature>> getHashMap(){ ArrayList<Feature> shapeList=new ArrayList<Feature>(); Feature shape1 = new Feature("1","AAA","URL1","",""); Feature shape2 = new Feature("2","AAA","URL2","",""); Feature shape3 = new Feature("4","AAA","URL3","",""); shapeList.add(shape1); shapeList.add(shape2); shapeList.add(shape3); ArrayList<Feature> sizeList=new ArrayList<Feature>(); Feature size1 = new Feature("5","AAA","","1.3","2.1"); Feature size2 = new Feature("7","AAA","","2.5","3.0"); Feature size3 = new Feature("11","AAA","","3.3","3.8"); Feature size4 = new Feature("24","AAA","","3.3","3.8"); sizeList.add(size1); sizeList.add(size2); sizeList.add(size3); sizeList.add(size4); ArrayList<Feature> MaterialList=new ArrayList<Feature>(); Feature Material1 = new Feature("43","AAA","","",""); Feature Material2 = new Feature("44","AAA","","",""); Feature Material3 = new Feature("57","AAA","","",""); MaterialList.add(Material1); MaterialList.add(Material2); MaterialList.add(Material3); HashMap<String,List<Feature>> map=new HashMap<String,List<Feature>>(); map.put("Shape", shapeList); map.put("Size", sizeList); map.put("Material", MaterialList); return map; } }
Flex中的index.mxml :
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Button click="getHashMap()" label="GetHashMap" x="43" y="134"/> <mx:List id="lst" dataProvider="{acShape}" labelField="FeatureName" x="10" y="164"/> <!--<mx:DataGrid id="dg" dataProvider="{acShape}" x="12" y="167"/>--> <mx:RemoteObject id="roHashMap" destination="testHashMap" result="resultHashMap(event)" fault="faultHashMap(event)"/> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.controls.Alert; import hashmap.Feature; private var sResultHashMap:String; [Bindable] private var obj:Object = new Object(); [Bindable] private var acShape:ArrayCollection = new ArrayCollection(); private function getHashMap():void{ roHashMap.getHashMap(); } private function resultHashMap(event:ResultEvent):void{ acShape.removeAll(); obj = event.result as Object; for each(var fea:Feature in obj.Shape){ acShape.addItem(fea); trace(fea.FeatureName); } } private function faultHashMap(event:FaultEvent):void{ sResultHashMap = event.fault.message.toString(); Alert.show("error:\n" + sResultHashMap); } ]]> </mx:Script> </mx:Application>
WebRoot\WEB-INF\flex\remoting-config.xml 中添加:
<destination id="testHashMap"> <properties> <source>hashmap.TestHashMap</source> </properties> </destination>
发表评论
-
Flex从swf中加载资源和类
2013-12-10 09:37 728需要为直播播放器做几个新的样式,想将每个样式的布局XML和 ... -
swf加载swf的一些问题
2013-03-20 17:31 6871,swfParent 加载 swfChild,如果有交互, ... -
NetStream appendBytes 一点经验
2013-03-20 16:25 2542最近在做基于 NetStream ... -
【译】HTML5还需要什么才能击败Flash(part 2)
2012-04-01 17:53 0What else does HTML5 need to ... -
【译】HTML5还需要什么才能击败Flash(part 1)
2012-04-01 16:36 1057What else does HTML5 need to de ... -
AS 函数作用域、函数闭包、限界方法
2012-03-30 10:21 1433作用域链(scope chain): 任何时候函数开始 ... -
在AS3中自定义全局方法
2012-03-29 11:17 922http://en.flash-ripper.com/2007 ... -
Flex Class object(类对象)构成、traits和prototype
2012-03-29 10:59 1524先贴张图: 每个矩形代表一个对象。CA代表class ... -
使用flex sdk3.6的asdoc遇到的问题及解决方法
2012-03-26 10:24 1901想要对一个组件项目导出asdoc。组件的sdk是3.6,但使用 ... -
UIComponent添加Image不显示
2012-03-18 17:32 988在UIComponent中添加Image组件,图片不显示。 ... -
Flex优化技巧
2012-03-30 09:46 863http://www.jb51.net/article/182 ... -
Flex中多个柱状图和折线图的问题
2012-02-28 17:53 1945做了个柱状图和折线图的混合图表,2根3D的柱子,6根折线,遇到 ... -
AdvancedDatagrid的dataprovider属性
2012-02-22 10:15 781高级dataGrid的dataProvider的set方法里并 ... -
Sprite的宽高设置及Flex组件的混淆
2012-02-02 10:23 1657由于Bitmap和InteractiveObject同级,都继 ... -
Flex SDK3.5 PollingChannel.as 存在内存泄露bug的一种解决方法
2011-12-31 15:32 1263bug见前面的一篇文章: http://xltank.ite ... -
TextInput的ErrorString样式
2011-10-25 13:08 871http://blog.minidx.com/2008/05/ ... -
【转】Flash Player的 mm.cfg文件
2011-10-08 17:17 5157http://jpauclair.net/mm-cfg-sec ... -
Flex trace() 保存路径
2011-10-08 17:11 1057http://help.adobe.com/en_US/fle ... -
给ItemRenderer传参
2011-08-18 17:19 1435给ItemRenderer传递初始参数,可以根据参数灵活生成I ... -
AdvancedDatagrid改变行的颜色
2011-08-16 15:25 1581最早我尝试重写AdvancedDatagrid的drawRow ...
相关推荐
BlazeDS通信到Java的PureMVC——Flex框架,BlazeDS的服务器配置比较麻烦,这里使用的是直接下载blazeds_turnkey_3-0-0-544.zip中的tomcat BlazeDS模板路径为: blazeds_turnkey_3-0-0-544.zip解压后路径\tomcat\...
BlazeDS是一个基于服务器的Java远程调用(remoting)和Web消息传递(messaging)技术,使得后台的Java应用程序和运行在浏览器上的Flex应用程序能够相互通信。
blazeds.war blazeds
Flex技术本身和Java就有很强的关联性,它提供了一个基于Eclipse的IDE和BlazeDS.BlazeDS是个基于服务端的Java远程调用和Web消息的一个开源的技术。有许多应用都是以Java为后端处理的。Flex用于前端。由于Java和Flex...
Spring BlazeDS Integration,Flex通过remoteObject与java通讯,附带例子 文档
包含blazeds.war blazeds-spring.war 以及解压后的blazeds,blazeds-spring文件夹, 可直接拷贝到javaee项目下的WebRoot文件夹下
BlazeDS入门:HTTP Service BlazeDS入门:HTTP Service BlazeDS入门:HTTP Service
Blazeds入门教程.doc
blazeds4整合spring3 这是我新近研究的方法 与整合spring2.5以下的方法有不同了,(看过一些教程觉得不是很好,用起来不顺手) 最终参考了官方的sample,得到了这个不错的整合方法。 把要用blazeds公开给flex的java...
blazeDS war包及Flex结合blazeDS的入门程序及操作步骤比较适合入门选手
Using BlazeDS and Flex integrated。
flex 工具 blazeds
blazeds与spring的结合使用项目源码
JAVA通过BlazeDS与FLEX通信 BlazeDS.zip java项目,使用MYECLIPSE导入 FlexJavaServer.fxp FLEX项目,使用FLASHBUILDER4.5导入
Flex Blazeds入门教程 写的很不错的教程
最简单的BlazeDS实现flex与java通信..无积分下载...最简单的BlazeDS实现flex与java通信..无积分下载...最简单的BlazeDS实现flex与java通信..无积分下载...最简单的BlazeDS实现flex与java通信..无积分下载...最简单的...
BlazeDS开发者指南中文版,很详细的描述了BlazeDs的基本原理,开发、配置过程。
BlazeDS配置指南 tomcat安装 xml配置 flex与blazeDs
flex使用blazeds与java通信配置说明,包括java使用spring框架,blazeds调用spring bean
blazeds配置步骤及源码,导入即可运行