MyEclipse6.5整合flex實現與java簡單通訊過程中遇到的問題和注意事項

來源:互聯網
上載者:User

本人在實現此功能的過程中,費了不少勁,才實現。以下內容有些摘自網上,在這裡只是把自己遇到的問題記錄下來,以便以後查閱。

一:首先安裝好myeclipse6.5,設定好jdk環境。

二:安裝flexbuilder的eclipse外掛程式版,安裝過程中注意選擇myeclipse的路徑。要選擇myeclipse6.5下的eclipse檔案夾。

三:在安裝好的flexbuilder目錄中找到sdks檔案夾,將其複製到myeclipse6.5目錄下的eclipse檔案夾中,然後配置外掛程式(或者把flexbuilder下中eclipse下的features和plugins分別複製到myeclipse6.5目錄下的eclipse檔案夾下對應的檔案夾中或者採用其他配置外掛程式的方法,我建議採用建立link檔案夾,建立link檔案的方法)

四:當一切環境準備好後,就開始了flex與java通訊。具體過程如下

http://blog.csdn.net/roc230/archive/2010/06/07/5652746.aspx

這是一位csdn朋友的部落格,裡面介紹的很詳細,這裡不做更詳細的介紹。只是這裡自己用的是blazed,不是lcd

blazed:blazeds-turnkey-3.2.0.3978
是:http://flexorg.wip3.adobe.com/blazeds/3.0.x/milestone/3978
/blazeds-turnkey-3.2.0.3978.zip(一般解壓後找到blazed檔案,將其放到tomcat安裝目錄下的webapps檔案夾下即可。具體的可以參考網上更多的資訊)

五:相應的工程建好後,就可以進行相應的程式編寫

首先建立java類

package com.oraro.flex;

public class Flex {
    public String sayString(String str){
        System.out.println("click here!");
        return "hello" + str;
       
    }
}
然後修改相應的flex檔案

<?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.FaultEvent ;
              import mx.controls.Alert;
    import mx.rpc.events.ResultEvent ;
       [Bindable]
       private var helloResult:String ;
       private function sayHelloTo(): void {
           Alert.show(inputText.text);
         ro.sayString(inputText.text);
         }
        private function resultHandler ( event:ResultEvent ): void {
           helloResult = event.result as String ;
              }
      ]]>
      </mx:Script>
         <mx:RemoteObject id ="ro" destination = "flex" result = "resultHandler(event)" />
          <mx:HBox width = "100%">
            <mx:TextInput id = "inputText"/>
            <mx:Button label = "Submit" click = "sayHelloTo()"/>
         </mx:HBox >
        <mx:Label text = "{helloResult}"/>
</mx:Application>

接著在remoting-config.xml檔案中添加

 <destination id="flex">
        <properties>
            <source>com.oraro.flex.Flex</source>
        </properties>
    </destination>

以下內容

以上工作做完後,就完成了flex與java的通訊。當然通訊方式是通過RemoteObject實現的。

六:最後有一點需要注意的

就是要把你的Flex Server下的Context root配置 ,改成和你項目同名。

否則會報錯誤,如:

'http://localhost:8080/WebRoot/messagebroker/amf'路徑不對

編譯的時候出現faultCode:Client.Error.MessageSend faultString:'Send failed'
faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed:
HTTP: Status 404: url:
'http://localhost:8080/WebRoot/messagebroker/amf''這樣的錯誤。

 

 

當然,也可以分別建立flex和javaweb工程,然後再做相應的配置,在這裡就不具體的敘述了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.