Flex与SSH集成
Flex与SSH集成 -- ::| 分类: flex |举报|字号 订阅
Flex与SSH集成
,下载blazeds_bin_3---.zip 包,将其解压 取下blazeds.war包 更改为blazeds.rar ,并解压
将上一步解压的web-inf/lib/下的包复制到工程的lib下
,将flex文件夹 复制到工程的web-inf下
将classes下的文件复制到工程的src下
5在web.xml中加入 <!-- flex -->
<servlet>
<servlet-name>flex</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/flex-application-config.xml</param-value>
</init-param>
<load-on-startup></load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>flex</servlet-name>
<url-pattern>/ssh/*</url-pattern>
</servlet-mapping>
<!-- end flex -->
6,在src下建一个flex-application-config.xml文件
加入
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">
<flex:message-broker/>
<!— 下面是表示 在spring配置文件中配置的bean-->
<flex:remoting-destination ref="flowServer"/>
</beans>
以下内容
6,加入flex与spring所依赖的包
Flex与SSH集成 - 花落谁家 - zhangcb666的博客 7 编写 java 类 1> 编写类体DeptNode.class package com.svse.entity.bean; import java.util.ArrayList;
import java.util.List;
/***
* 注: 此类可以不用和Flex映射 ,因为在Flex端,我们不用把Object对象强转为此对象
**/
public class DeptNode { private int id;
private String name;
private DeptNode parent; private List<DeptNode> children = null; public DeptNode(){}
public DeptNode(int id ,String name){
this.id = id;
this.name = name;
}
/*************get and set 省略****************/ }
> 编写接口IflowServer.class
package com.svse.server; import java.util.List;
import com.svse.entity.bean.DeptNode; public interface IFlowServer {
//得到部门
List<DeptNode> getDeparts(int deptId);
} > 编写实现类
package com.svse.server.impl; import java.util.List; import com.svse.entity.bean.DeptNode;
import com.svse.server.IFlowServer; public class FlowServer implements IFlowServer { //得到部门
public List<DeptNode> getDeparts(int deptId){
List<DeptNode> list = new ArrayList<DeptNode>();
DeptNode node = new DeptNode();
node.setId();
node.setName("父节点11");
node.setChildren(this.getChild(, "aa")); list.add(node); DeptNode node2= new DeptNode();
node2.setId();
node2.setName("父节点22");
node2.setChildren(this.getChild(, "bb")); list.add(node2); return list;
} private List<DeptNode> getChild(int count,String name){
List<DeptNode> list = new ArrayList<DeptNode>();
for(int i = ; i < count; i++){
DeptNode node3 = new DeptNode();
node3.setId(i);
node3.setName(name+""+i);
list.add(node3);
}
return list;
} }
} 在spring中注入
<bean id="flowServer" class="com.svse.server.impl.FlowServer"/>
注:此处的Id,就是在flex-application-config.xml中的
<flex:remoting-destination ref="flowServer"/>配置的ref值 编写flex代码 <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.rpc.remoting.mxml.RemoteObject;
import bean.FileAction;
import mx.collections.ArrayCollection;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
/**
* 从服务器请示数据
* */
function loadDept():void{
var remote:RemoteObject = new RemoteObject();
remote.destination="flowServer";
remote.endpoint="/ssh2-flex/messagebroker/amf";
remote.getDeparts();
remote.addEventListener(ResultEvent.RESULT,resultHander1);
remote.addEventListener(FaultEvent.FAULT,fault);
}
/**
* 请示成功后,调用的方法
* */
function resultHander1(event:ResultEvent):void{
//在此只用转化为集合对象,不用考虑集合对象中的对象
var list:ArrayCollection = event.result as ArrayCollection;
this.deptList.dataProvider = list;
}
/**
* 初 始化
* */
function init():void{
var xmlArray:ArrayCollection = new ArrayCollection([
{"name":"上海","selected":false,"children":[{"name":"黄浦","selected":false},
{"name":"浦东","selected":false}]},
{"name":"北京1","selected":false,"children":null}
]);
//Tree对象默认会取chilren为子节点 deptList.dataProvider = xmlArray;
} /**
* 出错后调用的方法
* */
function fault(event:FaultEvent):void{
Alert.show("error");
}
/**
* 双击调用的方法
* */
function showMsg():void{
var st:String = deptList.selectedItem.id +" "+deptList.selectedItem.name;
Alert.show(st);
}
]]>
</mx:Script>
<mx:Label />
<mx:HBox>
<mx:Button label="加载数据" click="loadDept()" fontSize="" />
<mx:Tree id="deptList" labelField="name" width="" height="" itemDoubleClick="showMsg()" />
</mx:HBox>
</mx:Application>
注:Java类加也可返回xml格的数据,供flex调用,具体请查看相关文档
Flex与SSH集成的更多相关文章
- java:Spring框架3(AOP,SSH集成Demo)
1.AOP: Spring提供了4种实现AOP的方式: 1.经典的基于代理的AOP 2.@AspectJ注解驱动的切面 3.纯POJO切面 4.注入式AspectJ切面 aop.xml: <?x ...
- DWR以及SSH集成DWR
之前只是单独接触了DWR,知道一个基本的开发流程. web.xml配置文件: <!-- 配置Dwr信息 --> <servlet> <servlet-name> ...
- SSH集成log4j日志环境[转]
第一步:在web.xml初始化log4j <context-param> <param-name>log4jConfigLocation</param-name> ...
- SSH集成(Struts+Spring+Hibernate)
环境:struts2.3.Xspring4.0.0hibernate4.2 思路:从下开始往上集成;层与层之间没有关系;在集成的时候,只关注当前集成的那个层的内容; 1,创建一个空的web项目;重新定 ...
- SSH集成log4j日志环境
第一步:在web.xml初始化log4j <context-param> <param-name>contextConfigLocation</param-name> ...
- SSH集成cxf 发布restful webservice
首先讲一下什么是restful webservice ,这个问题网上一搜有很多博文去长篇大论的介绍它,但是最后你看完了也会觉得云里雾里的,所以我在这里简单的讲一下我理解的rest webservice ...
- ssh集成
导入pom依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w ...
- SSH集成开发框架开发步骤
1. 环境搭建 a)添加Struts框架的支持 b)添加spring框架的支持(选中5个类库,且Copy类库到WEB-INF/lib目录下) c)在Eclipse 中,DataBase Explor ...
- SSH集成步骤
1 在goodspeed.web.model下建立*类(空的构造,属性访问与设置),同时配置*.hbm.xml文件与数据库挂起来2 在goodspeed.web.dao建立*Dao和*Daoimpl类 ...
随机推荐
- Python cookielib 模块
什么是 cookie : 指某些网站为了辨别用户身份,进行 session 跟踪而储存在用户本地终端上的数据,通常以 txt 文件形式存储.比如你登录了淘宝,浏览器就会保存 cookie 信息,这样我 ...
- Qt监控Access数据库
配置文件setup.ini内容 [General] DBFilePath=C:/Users/WangGang/Desktop/Database1.accdb DBUserName= DBPasswor ...
- 计算从ios照片库中选取的图片文件大小
本文转载至:http://blog.csdn.net/longzs/article/details/8373586 从 iphone 的 照片库中选取的图片,由于 系统不能返回其文件的具体路径,所以这 ...
- Oracle里 用sql*plus 登陆时,用户名和密码是多少啊?
Oracle里sql*plus的用户名即system用户,密码是自己设置的密码. 如果密码忘记,可通过如下方法重置. 1.win键+R键,输入cmd,打开命令提示符. 2.输入sqlplus /nol ...
- ajax的历史
ajax (AJAX开发) 编辑 AJAX即“Asynchronous Javascript And XML”(异步JavaScript和XML),是指一种创建交互式网页应用的网页开发技术. AJAX ...
- JS基本动画
<style type="text/css"> .color_red { background: red; } div { position: absolute; to ...
- [置顶] think in java interview-高级开发人员面试宝典代码示例
下载资源地址为: http://download.csdn.net/detail/lifetragedy/6379755 这是think in java interview中的代码示例,包括JAVA基 ...
- 学习坤哥的replaceTpl方法
学习坤哥的方法之后自己写的replaceTpl function replaceTpl(tpl, data){///////////////没有传入可让用户自己定义的方式进行替换,不够灵活 ...
- 关于layer.photos即照片显示的问题。
在layer组件中,照片显示是不常用,今天做了一些不伤了. 在这里写出来,以备后用. 其中注意几个问题, 1.格式问题. 2.路径问题. 不同的layer有不同的格式,查看layerAPI中发现的格式 ...
- Windows Phone 7 检查手机网络
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Wi ...