`
vissul
  • 浏览: 190462 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

flex java 整合

阅读更多

今天终于将flex和 java 整合在一起工程上了,一天的辛苦没有白费,希望给志同道合者一个捷径,不要像我一样没头苍蝇似的鼓弄了一天! 马上推出个人原创版配置笔记

step 1.下载 flex 3.0 plugin 插件 装在 我的myeclipse 6.0 上

   1) 下载地址:http://trials.adobe.com/Applications/Flex/FlexBuilder/3/FB3_WWEJ_Plugin.exe

   2)安装插件

    将flex plugin 安装目录里面的com.adobe.flexbuilder.update.site 文件夹下面的features 文件夹,plugins 文件夹 和 site.xml 文件 添加在myeclipse 文件夹的eclipse文件夹内.

              将 flex plugin 安装目录里面的eclipse 文件夹下面的features 文件夹,plugins 文件夹  覆盖在myeclipse 文件夹的eclipse文件夹内.(防止更新)

step1 完

 

step 2.下载 blazeds  

http://download.macromedia.com/pub/opensource/blazeds/blazeds_bin_3-0-0-544.zip

解压之后是个 blazeds. war包,把它放在tomcat 的webapp里面 部署一下就会释放出来一个类似与工程文件的东西(里面就有将flex 和java 合并的重要文件)

step 2 完

 

step 3 . 合并 web project 和flex 工程

 新建一个web project 工程

把 blazeds.war 部署之后的 flexweb 文件夹里面的lib 目录copy 到 web-inf 的lib目录里

把 blazeds.war 部署之后的 flexweb 文件夹里面的flex 目录copy 到 web-inf 下面

替换 web.xml 这步很重要,容易忘记,忘记你就死定了,慢慢调去吧!

都加完了把? 这时候把web project 工程部署在tomcat上面上他跑起来, 之后在加入flex ,单击工程右键flex project natrue --- >  add flex project natrue

第一步见2.jpg

第二步见1.jpg

都整完了看一下配置是否正确,正确就可以进行 step 4了。

step 3 完


step 4 . 让flex调用java类(这tm才是我们想要到达的目的!)

在src 里面见一个包,包里面见一个类 包名.类名 whatever

开始配置 remoting-config.xml

在里面加入

    <destination id="hello">
         <properties>
             <source>com.Hello</source>
          </properties>
    </destination>

hello 是别名

com.hello 是类的全路径

 

然后配置services-config.xml(这个tm那个介绍配置上面也没写,你说你到是告诉一声啊,向我们这种粗心大意的人那在乎啊,就因为这个没配置我就浪费了2个小时,我只能对那些网上发帖子教人家配置的大牛们,说一声:"大哥在说的详细点被")

        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://127.0.0.1/flexweb/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint" />
    
        </channel-definition>

        <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
            <endpoint url="https://127.0.0.1/flexweb/messagebroker/amfsecure " class="flex.messaging.endpoints.SecureAMFEndpoint"/>
            <properties>
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>

        <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://127.0.0.1/flexweb/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
            <properties>
                <polling-enabled>true</polling-enabled>
                <polling-interval-seconds>4</polling-interval-seconds>
            </properties>
        </channel-definition>

主要就是把那个 url 改成自己的工程 路径,太tm 重要了!

step 4 完


使用 :

写一个hello类

public class Hello {
    public String hello(String name){
        System.out.println(name);
        return "hello"+name;
    }
}

一个mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
function gg(evnet:ResultEvent):void{
var ff:String = evnet.result as String;
ggg.text = ff;
}
function remotingSayHello():void{
var sname:String = nameInput.text;
h.hello(sname);
}
]]>
</mx:Script>
<mx:RemoteObject destination="hello" id="h"
result="gg(event)" endpoint="http://127.0.0.1/flexweb/messagebroker/amf" >
</mx:RemoteObject>
<mx:TextArea id="ggg" x="109" y="122"/>
<mx:Button label="say hello" click="remotingSayHello();" x="144" y="193"/>
<mx:TextInput id="nameInput" x="109" y="73"/>
<mx:Label text="name" x="47" y="75"/>
</mx:Application>

 

你要是死也找不到为什么他不能出数据看一下红色区域!

                                                                               谨以此文献给那些和我一样奋战在编程第一线的IT民工们!

  • 大小: 52.6 KB
  • 大小: 62.6 KB
分享到:
评论
5 楼 blind 2009-08-05  

  表述的有点问题。不过还是搞好了.多谢
4 楼 vissul 2009-04-04  
徐晶鑫 写道

不成功呀&nbsp; 楼主

呵呵,这种方法太麻烦了,不如试试spring-flex-1.0.0-M2,整合更自然
3 楼 徐晶鑫 2009-04-04  
不成功呀  楼主
2 楼 天峰5 2008-11-10  
哎呀
  我也搞了一个下午
  呵呵   
  楼主这个帖太好了
  谢谢
1 楼 fcm915 2008-10-28  
LZ 辛苦

相关推荐

Global site tag (gtag.js) - Google Analytics