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集成的更多相关文章

  1. java:Spring框架3(AOP,SSH集成Demo)

    1.AOP: Spring提供了4种实现AOP的方式: 1.经典的基于代理的AOP 2.@AspectJ注解驱动的切面 3.纯POJO切面 4.注入式AspectJ切面 aop.xml: <?x ...

  2. DWR以及SSH集成DWR

    之前只是单独接触了DWR,知道一个基本的开发流程. web.xml配置文件: <!-- 配置Dwr信息 -->  <servlet>   <servlet-name> ...

  3. SSH集成log4j日志环境[转]

    第一步:在web.xml初始化log4j <context-param> <param-name>log4jConfigLocation</param-name> ...

  4. SSH集成(Struts+Spring+Hibernate)

    环境:struts2.3.Xspring4.0.0hibernate4.2 思路:从下开始往上集成;层与层之间没有关系;在集成的时候,只关注当前集成的那个层的内容; 1,创建一个空的web项目;重新定 ...

  5. SSH集成log4j日志环境

    第一步:在web.xml初始化log4j <context-param> <param-name>contextConfigLocation</param-name> ...

  6. SSH集成cxf 发布restful webservice

    首先讲一下什么是restful webservice ,这个问题网上一搜有很多博文去长篇大论的介绍它,但是最后你看完了也会觉得云里雾里的,所以我在这里简单的讲一下我理解的rest webservice ...

  7. ssh集成

    导入pom依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w ...

  8. SSH集成开发框架开发步骤

    1.  环境搭建 a)添加Struts框架的支持 b)添加spring框架的支持(选中5个类库,且Copy类库到WEB-INF/lib目录下) c)在Eclipse 中,DataBase Explor ...

  9. SSH集成步骤

    1 在goodspeed.web.model下建立*类(空的构造,属性访问与设置),同时配置*.hbm.xml文件与数据库挂起来2 在goodspeed.web.dao建立*Dao和*Daoimpl类 ...

随机推荐

  1. 关于android定位的坐标系问题

    按照正常的思路,我们通过GPS或者基站定位等方式获取到经纬度信息后,把它放到地图上,就能够完成定位.但实际上,我们很有可能会在实际操作中发现,我们的定位出现了较大的偏移.这是因为我国出于国家安全(或者 ...

  2. UIImageView 和 UIWebView 小结

    本文转载至:http://www.cnblogs.com/huangdongcheng/archive/2011/11/21.html 1.UIImageView的讲解 (1)初始化 UIImageV ...

  3. jquery类似方法的比较(一)

    1. $(div + p) & $(div ~ p) & $(div p) & $(div > p) $(div + p)选择紧挨在div后面的P元素 $(div ~ p ...

  4. Android Processes and Threads

    Processes and Threads When an application component starts and the application does not have any oth ...

  5. myBatis调用postgreSQL存储过程

    1.调用没有OUT参数的存储过程: 创建存储过程: create or replace function get_code(a1 varchar(32)) returns varchar(32) as ...

  6. SSL安装方法一:在Windows Server 2008安装SSL证书(IIS 7.0)

    购买的是GlobalSign 公司的通配符域名型SSL 大致的意思就是“通配符公用名填写*.域名.com,这个下面的所有子域名是不受数量限制的,*可以换成任意字符” 1 生成数字证书签名请求文件(CS ...

  7. 公民身份号码校验码算法(C#版)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. Java学习记录-Lambda表达式示例

    List<Integer> userIds=userInfoList.stream().map(m->m.getUserId()).collect(Collectors.toList ...

  9. 使用google字体发生http://fonts.gstatic.com/s/ubuntu/v8/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2

    我在使用adminTLE后台模板时,有时候会有 http://fonts.gstatic.com/s/ubuntu/v8/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJh ...

  10. Optimal Milking---poj2112(多重匹配+Floyd+二分)

    题目链接:http://poj.org/problem?id=2112 题意:K个挤奶器(编号1~K),每个挤奶器每天最多供M头奶牛.共有C头奶牛(编号K+1~K+C).挤奶器和奶牛间有不同长度的路. ...