- 浏览: 959042 次
- 性别:
- 来自: 珠海
文章分类
最新评论
-
Yunjey:
Yunjey 写道这样子的话、grid中的editable如何 ...
Flex创建可编辑以及分页的DataGrid -
Yunjey:
这样子的话、grid中的editable如何设置啊?!
Flex创建可编辑以及分页的DataGrid -
di1984HIT:
写的很好~~
JCalendar组件 -
sanny81:
此文真棒!感谢一路风尘的奉献!
但我有一疑 ...
Filter发送自定义数据详解 -
umgsai:
求完整demo umgsai@126.com
Flex和Jsp创建用户登入系统
不知道为什么一直有一个想法把CUBlog排行榜的数据提取出来放在Flex的DataGrid中浏览。上网看过了关于html解析有很多开源的比如
html parser等。但好像都要写蛮多的代码才能实现。一个比较简单快速的方法就是使用正则表达式了。刚学习,顺便练习下。效果图:
Flex和后台Java的沟通方式是采用remoteObject。直接贴代码把,很简单不用解释。
前台Flex处理:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Style> </mx:Style> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; import mx.collections.ArrayCollection; import com.adobe.serialization.json.JSON; [Bindable] private var dataArray:ArrayCollection; private function initDataGrid():void{ dataArray = new ArrayCollection(); } private function getBolgListFun():void{ var blogIndex:int; blogIndex = showId.selectedIndex; getBlog.getList(blogIndex); labTxt.text="请稍候,正在读取博客列表...你选择查看"+showId.selectedItem.toString()+"的排行榜!"; } private function getBlogListResult(event:ResultEvent):void{ var rawArray:Array; var arraySize:int; var rawData:String = event.result as String; rawArray = JSON.decode(rawData) as Array; dataArray = new ArrayCollection(rawArray); arraySize = dataArray.length; labTxt.text="读取成功..."; } ]]> </mx:Script> <mx:RemoteObject id="getBlog" destination="getBlogList" showBusyCursor="true" result="getBlogListResult(event)"/> <mx:Panel x="10" y="40" width="681" height="430" layout="absolute" title="CU博客排行版"> <mx:DataGrid id="blogGrid" x="0" y="0" width="661" height="284" dataProvider="{dataArray}" creationComplete="{initDataGrid()}" verticalScrollPolicy="on" fontFamily="Times New Roman" fontSize="12" color="#0142FC"> <mx:columns> <mx:DataGridColumn headerText="名次" dataField="no"/> <mx:DataGridColumn headerText="博客名称" dataField="blog" width="220"/> <mx:DataGridColumn headerText="用户名" dataField="user" width="80"/> <mx:DataGridColumn headerText="技术文章" dataField="technique"/> <mx:DataGridColumn headerText="总文章" dataField="total"/> <mx:DataGridColumn headerText="访问量" dataField="visit"/> <mx:DataGridColumn headerText="评论量" dataField="common"/> <mx:DataGridColumn headerText="推荐数" dataField="recommand"/> </mx:columns> </mx:DataGrid> <mx:Button id="getBtn" x="10" y="323" label="读取更新" width="474" height="35" click="getBolgListFun()" fontFamily="Times New Roman" fontSize="12" color="#02FEF5"/> <mx:Label id="labTxt" x="0" y="292" width="626" height="23" fontFamily="Times New Roman" fontSize="12" color="#FE0315"/> <mx:ComboBox x="492" y="323" width="134" height="35" fontSize="12" fontFamily="Times New Roman" color="#A103FC" selectedIndex="3" id="showId"> <mx:dataProvider> <mx:Array> <mx:String>技术文章</mx:String> <mx:String>推荐总数</mx:String> <mx:String>总文章数</mx:String> <mx:String>总访问量</mx:String> <mx:String>评论总数</mx:String> </mx:Array> </mx:dataProvider> </mx:ComboBox> </mx:Panel> </mx:Application>
后台Java处理:
package cublog; /* * @Author: yexin218 * @Email:feixianyexin@qq.com */ import java.net.*; import java.io.*; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class PaiHangBang { public static void main(String[] args){ PaiHangBang p = new PaiHangBang(); System.out.println(p.getList(3)); } public String getList(int selectIndex){ String blogList=""; int showBlogNo=25;//the no of blog to show StringBuffer document = new StringBuffer(); try{ URL url = new URL("http://blog.chinaunix.net/top/?type="+selectIndex); URLConnection conn = url.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = null; String result=null; while ((line = reader.readLine()) != null) document.append(line+"|"); result = document.toString().replaceAll("<[^>]*>","").replaceAll("\\s+",""); result = result.substring(result.indexOf("推荐数")+6, result.indexOf("关于我们")); String array[] = result.split("\\|"); String str=""; for(int i=0;i<array.length;i++){ if(!array[i].equals("")){ str+=array[i]+"|"; } } JSONArray blogListArray = new JSONArray(); JSONObject blogObj = new JSONObject(); String newBlogArray[] = str.split("\\|");//here is all the item independently for(int i=0;i<showBlogNo;i++){//The head 20 items blogObj.put("no", newBlogArray[8*i]); blogObj.put("blog", newBlogArray[8*i+1]); blogObj.put("user", newBlogArray[8*i+2]); blogObj.put("technique", newBlogArray[8*i+3]); blogObj.put("total", newBlogArray[8*i+4]); blogObj.put("visit", newBlogArray[8*i+5]); blogObj.put("common", newBlogArray[8*i+6]); blogObj.put("recommand", newBlogArray[8*i+7]); blogListArray.add(blogObj); } blogList = blogListArray.toString(); reader.close(); }catch(MalformedURLException e){ e.printStackTrace(); }catch(IOException ex){ ex.printStackTrace(); } System.out.println(blogList); return blogList; } }
前后台之间需要的remote-config.xml配置。增加以下语句:
<destination id="getBlogList"> <properties> <source>cublog.PaiHangBang</source> </properties> </destination><destination id="getBlogList"> <properties> <source>cublog.PaiHangBang</source> </properties> </destination>
Eclipse工程文件下载:http://download.csdn.net/source/561370
发表评论
-
Rounded Colorized Image Borders
2009-05-16 22:24 1047This week I ran across a really ... -
Flex使用自定义皮肤和字体
2009-03-29 14:57 4188首先介绍两个Flex皮肤网站: 1. Skins and Th ... -
Flex--XML转换成ArrayCollection
2009-03-28 23:24 9579xml数据: <?xml version="1 ... -
Flex使用弹出窗口为DataGrid添加新数据
2009-03-28 21:01 2593经常在Demo中会看到列表,表格等方式来显示数据。当然有时候也 ... -
关于Flex使用Blazeds连接Java后台的一个注意笔记
2009-03-24 16:49 2183今天在做Flex程序测试的时候,发现之前可以通过Blazeds ... -
Flex-设置DataGrid被选择行的风格
2009-03-22 20:54 7171这里例子将展示如何使用用户自定义的item renderer来 ... -
Flex使用JSON格式与Java通信
2009-03-22 00:09 7284在使用Flex,Java,Json更新Mysql数据【高级篇】 ... -
Flex--主程序与弹出窗口之间传递数据
2009-03-20 23:08 2620主程序:TitleWindowDataTest.mxml & ... -
Flex中显示手型鼠标
2009-03-06 21:40 5184有些时候,我们需要在Flex组件上--Label或者Butto ... -
Flex与JSON及XML的互操作
2009-03-01 17:18 1857作者 Jack Herrington 译者 张凯 ... -
Flex代码格式化插件
2009-03-01 16:52 2713在7Yue 那里看到这个轻巧实用的Eclipse插件,它可以 ... -
使用Flex,Java,Json更新Mysql数据【高级篇】
2008-06-24 20:21 5789前面已经介绍如何使用Flex,java,json来更新dat ... -
Flex+Java Servlet文件上传实例
2008-06-23 21:05 20213资源都是来自网上。本实例将展示使用Flex和java serv ... -
Flex和Jsp创建用户登入系统
2008-06-22 16:16 4263在开始之前我们先来看下效果:【userName==passwo ... -
Flex中嵌入Google地图
2008-06-18 22:29 5934在我们开始之前,先来看一个例子:http://scriptpl ... -
Flex程序发布
2008-06-17 23:32 3976当你写好了一个Flex程序,想要按照某种方式发布。比如我们在 ... -
Flex自定义Alert窗口显示位置
2008-06-16 18:25 6276好像Flex3也没有找到可以直接使用的(x,y)的方法来指定A ... -
Flex支持滑轮滚动
2008-06-16 18:23 3401有些时候需要在Flex界面中支持鼠标的滑轮滚动功能,比如通过滑 ... -
Flex实现简单的Email发送
2008-06-14 16:35 4255本文主要介绍和实现怎么使用Flex-java来实现Em ... -
Flex创建可编辑以及分页的DataGrid
2008-06-13 16:32 14806之前那篇文章:使用Flex,Java,Json更新Mys ...
相关推荐
NIOS2软件架构解析读后感高手篇.pdf NiosII_SOPCBuilder_5_1_Labs_for_DE2.pdf NiosII之IDE属性配置(Sep29更新,静态密码:NiosII.cublog.cn).pdf NiosII之处理器操作模式及寄存器(Sep29更新,静态密码:NiosII....
解压密码:skyily.cublog.cn 第二版本 0.10.1 第0步骤: 1. 要求每个命令完成后,重新打印出提示符 2. 测试:ls cat 等命令 第1步骤:参数 1. 提示符中出现当前路径信息。 2. 测试命令“ls”,“ls<空格>”,“...
http://sxg.cublog.cn/ http://blog.chinaunix.net/u/8754/showart_1961481.html Important Notice: Althouth there are no malicious codes included, I do not issue any guarantee of any kind, use it at your...
SHELL经典笔试题及答案 小实例,欢迎大家一起探讨 File information 2009-8-21 磁针石:xurongzhong#gmail.com 博客:oychw.cublog.cn
WereWolf
出自博客:quietheart.cublog.cn 这篇文章讲述如何从硬盘上安装ubuntu,参考网上资源,并且亲身实践ubuntu9.10安装成功。总结并分享如下: 最简单介绍: =================== 1.准备文件: 1)grub4dos相关文件(grldr...
站点:http://wiki.freecode.com.cn 或 http://mirnshi.cublog.cn 历史版本: 0.21a 修订IPv6的RS 0.21 修订了许多问题 0.20b 支持与外部tcpserver通信 0.20a 进一步增强IPv6,支持LinkLocal,无状态自动配置,...
从 kevinsky.cublog.cn 整理的,感觉写的挺好的,传上来大家分享一下,也赚点分,呵呵
linux2.6.24 S3C2410下的网卡CS8900驱动 具体移植方法可以参考我的blog http://www.cublog.cn/u2/63560/showart_514147.html
ELF文件格式学习 From: http://danielwood.cublog.cn
学习nios的好资料 打开密码:NiosII.cublog.cn
转载于:|狼人◇_传说 http://werewolf.cublog.cn/
转载时请注明出处和作者 文章出处:http://danielwood.cublog.cn 作者:Daniel Wood
最新版本为2.3.1,有关URLTester的最新信息发布在http://aquester.cublog.cn上。 网址:http://blog.chinaunix.net/u2/64804/showart_1132881.html<br>下载:...
针对老版的supervivi进行了mach_type的修改(与FriendlyArm论坛的内核镜像不同),我的开发板是两年前的,用户...具体的文件系统可以到FriendlyArm的官方论坛下载:http://www.cublog.cn/u3/97285/showart_1967792.html
lenky0401个人博客将陆续推出对dlmalloc的解析(针对Doug Lea Malloc的最新版Version 2.8.3,未做说明的情况下以32位平台,8字节对齐作为假定平台环境设置考虑),由于个人水平有限,因此也不能完全保证对dlmalloc的...
站点:http://wiki.freecode.com.cn 或 http://mirnshi.cublog.cn 历史版本: 0.21a 修订IPv6的RS 0.21 修订了许多问题 0.20b 支持与外部tcpserver通信 0.20a 进一步增强IPv6,支持LinkLocal,无状态自动配置,...
NiosII之动态栈溢出检测功能,中文版的资料 蔡伟刚编写。 密码:NiosII.cublog.cn(区分大小写)
找到你的apache安装目录,找到httpd.conf文件, 搜索#listen这一句,在下面增加 代码如下:listen 800 ...# serveradmin webmaster@dummy-host2.phps教程hao.cublog.cn # documentroot /www/docs/dummy-host2.ph