java中ds任务,BlazDS与JAVA交互实例

这里只列出代码:

1.依赖包

0818b9ca8b590ca3270a3433284dd417.png

2.WEB-INF/web.xml

BlazeDS

BlazeDS Application

flex.messaging.HttpFlexSession

MessageBrokerServlet

MessageBrokerServlet

flex.messaging.MessageBrokerServlet

services.configuration.file

/WEB-INF/flex/services-config.xml

1

MessageBrokerServlet

/messagebroker/*

index.html

index.htm

3.Greeting.java

package org.wang.flexdemo;

import java.util.Map;

/**

* TODO

* @author: wb

* @update: 2012-3-7 下午4:58:08

*/

public class Greeting {

public Greeting(){}

public String greeting(String name){

String returnstr=name+" greeting!";

System.out.println(returnstr);

return returnstr;

}

public void showObject(Person person){

System.out.println("Method showObject() is start .......");

if(null==person) System.out.println("person is null");

System.out.println("person.name="+person.getName());

System.out.println("person.age="+person.getAge());

System.out.println("person.gender="+person.getGender());

System.out.println("person.mobile="+person.getMobile());

System.out.println("person.address="+person.getAddress());

System.out.println("Method showObject() is end .......");

}

public void showMap(Map map){

System.out.println("Method showMap() is start .......");

if(null==map) System.out.println("map is null");

for(Map.Entry entryMap:map.entrySet()){

System.out.println(entryMap.getKey()+"="+entryMap.getValue());

}

System.out.println("Method showMap() is end .......");

}

}

4.Person.java

package org.wang.flexdemo;

import java.io.Serializable;

/**

* TODO

* @author wangbo

* @update 2012-3-7 下午101421

*/

public class Person implements Serializable {

public String Name="";

public int Age=0;

public int Gender=0;

public String Mobile="";

public String Address="";

public Person(){}

/**

* @return name : return the property name.

*/

public String getName() {

return Name;

}

/**

* @param name : set the property name.

*/

public void setName(String name) {

Name = name;

}

/**

* @return age : return the property age.

*/

public int getAge() {

return Age;

}

/**

* @param age : set the property age.

*/

public void setAge(int age) {

Age = age;

}

/**

* @return gender : return the property gender.

*/

public int getGender() {

return Gender;

}

/**

* @param gender : set the property gender.

*/

public void setGender(int gender) {

Gender = gender;

}

/**

* @return mobile : return the property mobile.

*/

public String getMobile() {

return Mobile;

}

/**

* @param mobile : set the property mobile.

*/

public void setMobile(String mobile) {

Mobile = mobile;

}

/**

* @return address : return the property address.

*/

public String getAddress() {

return Address;

}

/**

* @param address : set the property address.

*/

public void setAddress(String address) {

Address = address;

}

}

5./WEB-INF/flex/remoting-config.xml

class="flex.messaging.services.RemotingService">

org.wang.flexdemo.Greeting

-------------------------------------------------------

Flex

-------------------------------------------------------

1./flexBlazeDSDemo/src/flexBlazeDSDemo.mxml

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

import mx.controls.Alert;

import mx.rpc.events.FaultEvent;

protected function button1_clickHandler(event:MouseEvent):void{

var iname:String=tiName.text;

say.greeting(iname);

}

protected function button1_clickHandler2(event:MouseEvent):void{

var person:Person=new Person;

person.Name="wan";

person.Age=26;

person.Gender=1;

person.Mobile="13669040351";

person.Address="湖南长沙";

say.showObject(person);

}

protected function button1_clickHandler3(event:MouseEvent):void{

var map={Name:"wan",Age:26,Gender:1,Mobile:"13669040351",Address:"湖南长沙"};

say.showMap(map);

}

protected function getFaultInfos(event:FaultEvent){

var str:String=event.fault.toString();

Alert.show(str);

}

]]>

2./flexBlazeDSDemo/src/Person.as

package

{

[Bindable]     [RemoteClass(alias="org.wang.flexdemo.Person")]     public class Person     {         public function Person()         {         }                  public var Name:String="";         public var Age:int=0;         public var Gender:int=0;         public var Mobile:String="";         public var Address:String="";     } }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值