BlazeDS整合Spring,adobe开发者中心有文章介绍:
http://www.adobe.com/devnet/flex/articles/spring_blazeds_integration.html
http://www.adobe.com/devnet/livecycle/articles/blazeds_spring_05.html
前几天在IBM developerWorks看到一篇文章,自己更改了一下:
1.服务端编程
用myeclipse8.0下载flash build4插件。首先建一个flex project,使用WTP创建flex/java组合项目,点next,在LCDS war文件中,找到自己下载的blazeds-turnkey中的blazeds.war文件。
完成之后在WEB-INF目录下flex目录中找到services-config.xml添加:
<factories>
<factory id="flexFactory" class="org.expressme.employee.mgmt.flex.FlexFactoryImpl"/>
</factories>
在remoting-config.xml中添加:
<destination id="flexService">
<properties>
<factory>flexFactory</factory>
<source>flexService</source>
<scope>application</scope>
</properties>
</destination>
注意这里的flexservice是Spring中的bean。不用spring需要写全路径。
FlexFactoryImpl.java实现如下:
public class FlexFactoryImpl implements FlexFactory {
private Log log = LogFactory.getLog(getClass());
public FactoryInstance createFactoryInstance(String id, ConfigMap properties) {
log.info("Create FactoryInstance.");
SpringFactoryInstance instance = new SpringFactoryInstance(this, id, properties);
instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));
return instance;
}
public Object lookup(FactoryInstance instanceInfo) {
log.info("Lookup service object.");
return instanceInfo.lookup();
}
public void initialize(String id, ConfigMap configMap) {
}
}
web.xml中添加spring支持就可以了,其他的不用更改。spring配置文件和以前的一样。具体代码在附件中。
2.客户端实现
EmployeeMgmt.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" creationComplete="queryAll();">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import org.expressme.employee.mgmt.Employee;
[Bindable]
private var employees : ArrayCollection = new ArrayCollection();
private function queryAll():void {
ro.queryAll();
}
private function resultHandler(event:ResultEvent):void {
employees = new ArrayCollection();
for each (var o : Employee in event.result as Array) {
employees.addItem(o);
}
}
private function queryByName():void {
var name : String = nameText.text;
if (name.length==0) {
queryAll();
}else{
ro.queryByName(name);
}
}
private function preCreateEmployee():void {
form_name.text = "";
form_title.selectedIndex = 0;
form_gender_male.selected = false;
form_gender_female.selected = false;
form_birth.text = "";
form_panel.visible = true;
}
private function deleteEmployee():void {
var item : Employee = employeeDataGrid.selectedItem as Employee;
if (item==null) {
Alert.show("Please select an employee first!", "Error");
}else {
ro.deleteEmployee(item.id);
employees.removeItemAt(employeeDataGrid.selectedIndex);
}
}
private function createEmployee():void{
ro.createEmployee(form_name.text,form_title.selectedItem,
form_gender_male.selected,form_birth.selectedDate);
}
]]> </fx:Script>
<fx:Declarations>
<s:RemoteObject id="ro" destination="flexService" result="resultHandler(event)"/>
</fx:Declarations>
<s:Label x="10" y="10" text="Employee Management" fontSize="24"/>
<s:TextInput x="10" y="53" width="322" id="nameText"/>
<s:Button x="340" y="53" label="Query" click="queryByName()"/>
<s:Button x="409" y="53" label="Create" click="preCreateEmployee()"/>
<s:Button x="481" y="53" label="Delete" click="deleteEmployee()"/>
<mx:DataGrid x="10" y="83" width="535" height="186" dataProvider="{employees}" id="employeeDataGrid">
<mx:columns>
<mx:DataGridColumn headerText="ID" dataField="id"/>
<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Title" dataField="title"/>
<mx:DataGridColumn headerText="Gender" dataField="gender"/>
<mx:DataGridColumn headerText="Birth" dataField="birth"/>
</mx:columns>
</mx:DataGrid>
<s:Panel x="128" y="160" width="298" height="191" title="Create New Employee" id="form_panel" visible="false">
<s:TextInput x="87" y="10" id="form_name"/>
<s:Label x="37" y="12" text="Name:"/>
<s:Label x="44" y="38" text="Title:"/>
<s:Label x="28" y="64" text="Gender:"/>
<s:Label x="43" y="90" text="Birth:"/>
<s:ComboBox x="87" y="36" id="form_title">
<s:dataProvider>
<mx:ArrayList>
<fx:String>CEO</fx:String>
<fx:String>Project Manager</fx:String>
<fx:String>Architect</fx:String>
<fx:String>Engineer</fx:String>
<fx:String>Designer</fx:String>
</mx:ArrayList>
</s:dataProvider>
</s:ComboBox>
<s:RadioButton x="86" y="62" label="Male" groupName="grp_gender" id="form_gender_male" value="true"/>
<s:RadioButton x="145" y="62" label="Female" groupName="grp_gender" id="form_gender_female" value="false"/>
<mx:DateField x="87" y="88" width="160" id="form_birth"/>
<s:Button x="87" y="118" label="Create" id="form_button_create" click="createEmployee()"/>
<s:Button x="159" y="118" label="Cancel" id="form_button_cancel" click="form_panel.visible=false"/>
</s:Panel>
</s:Application>
Employee.as
package org.expressme.employee.mgmt {
[RemoteClass(alias="org.expressme.employee.mgmt.Employee")]
[Bindable]
public class Employee {
public var birth : Date;
public var id : String;
public var name : String;
public var title : String;
public var gender : Boolean;
}
}
客户端实现有点小问题,就是每个ro事件处理都是resultHandler处理,导致增删操作后表格没数据显示。我也懒得改了,读者自己试试怎么实现……
分享到:
相关推荐
flex通过blazeds与java集成增删改查, 各位朋友,压缩包绝对没问题,我自己下载就可以解压
flex+java实现增删改查Dome,下载完后将blazeds.war下载jar copy过去即可运行,本程序只供参考。
blazeds4整合spring3 这是我新近研究的方法 与整合spring2.5以下的方法有不同了,(看过一些教程觉得不是很好,用起来不顺手) 最终参考了官方的sample,得到了这个不错的整合方法。 把要用blazeds公开给flex的java...
flex+java 通过blazeds完美结合实现增删改查功能
使用flex 4.5 + Spring 3.0 + Hibernate 3.3 + Cairngorm 2.2.1 + BlazeDS 3.3.0 + Spring BlazeDS Integration 1.0.3整合出的一个登录的小demo·
Flex技术本身和Java就有很强的关联性,它提供了一个基于Eclipse的IDE和BlazeDS.BlazeDS是个基于服务端的Java远程调用和Web消息的一个开源的技术。...在2008年末,Spring社区已经着手Spring BlazeDS整合的项目。
有问题可以去IT氧吧看看:http://www.ityangba.com,或许能找到答案哦 整合blazeds和spring需要的jar包 整合blazeds和spring需要的jar包
Flex blazeds-spring Flex blazeds-spring Flex blazeds-spring Flex blazeds-spring Flex blazeds-spring Flex blazeds-spring
Spring BlazeDS Integration,Flex通过remoteObject与java通讯,附带例子 文档
Flex PureMVC Flex BlazeDS Spring Hibernate 整合 里面一些图标是包双击可查看源代码
flex页面源码 博文链接:https://jhaij.iteye.com/blog/832478
Flex4+BlazeDS+Spring+Hibernate 整合源码博文源码
flex 结合spring,完成前后台数据传递。
Flex+blazeDS+Spring官方Demo,环境搭建,内含十几个例子,从易到难,包括spring消息,spring安全,注解方式和非注解配置文件方式,十分好用。内含有tomcat,可直接启动并运行用户手册。
flex,blazeds,spring,hibernate 整合小例子 不明白的可以去我的空间看资料讲解,里面没有lib 被我删了。
本课程主要是讲解Flex 4.6和ActionScript 3.0使用方法和技巧
本课程主要是讲解Flex 4.6和ActionScript 3.0使用方法和技巧
blazeds-spring3.0所有jar包 flex remoteobject服务方式