<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    The NoteBook of EricKong

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      611 Posts :: 1 Stories :: 190 Comments :: 0 Trackbacks

    Configure an existing J2EE web application to support BlazeDS by performing the following steps:
    1 Add the BlazeDS JAR files and dependent JAR files to the WEB-INF/lib directory.
    2 Edit the BlazeDS configuration files in the WEB-INF/flex directory.
    3 Define MessageBrokerServlet and a session listener in WEB-INF/web.xml.

    RPC service example
    The Remoting Service is one of the RPC services included with BlazeDS. The Remoting Service lets clients access methods of Plain Old Java Objects (POJOs) on the server.In this example, you deploy a Java class, EchoService.java, on the server that echoes back a String passed to it from the client. The following code shows the definition of EchoService.java:

    1 package remoting;
    2 public class EchoService
    3 {
    4     public String echo(String text) {
    5         return "Server says: I received '" + text + "' from you";
    6     }
    7 }
    8 


    The echo() method takes a String argument and returns it with additional text. After compiling EchoService.java,place EchoService.class in the WEB-INF/classes/remoting directory. Notice that the Java class does not have to import or reference any BlazeDS resources.
    Define a destination, and reference one or more channels that transport the data. Configure EchoService.class as a remoting destination by editing the WEB-INF/flex/remoting-config.xml file and adding the following code:

    <destination id="echoServiceDestination" channels="my-amf">
     
    <properties>
      
    <source>remoting.EchoService</source>
     
    </properties>
    </destination>

    The source element references the Java class, and the channels attribute references a channel called my-amf.Define the my-amf channel in WEB-INF/flex/services-config.xml, as the following example shows:

    <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
        
    <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
        
    <properties>
            
    <polling-enabled>false</polling-enabled>
        
    </properties>
    </channel-definition>

    The channel definition specifies that the Flex client uses a non-polling AMFChannel to communicate with the AMFEndpoint on the server.
    Note: If you deploy this application on the samples web application installed with BlazeDS, services-config.xml already contains a definition for the my-amf channel.The Flex client application uses the RemoteObject component to access EchoService. The RemoteObject component uses the destination property to specify the destination. The user clicks the Button control to invoke the remote
    echo() method:

    <?xml version="1.0"?>
    <!-- intro\intro_remoting.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">
    <mx:Script>
    <![CDATA[
     import mx.rpc.events.FaultEvent;
     import mx.rpc.events.ResultEvent;
     // Send the message in response to a Button click.
     private function echo():void {
        var text:String = ti.text;
        remoteObject.echo(text);
     }
     // Handle the recevied message.
     private function resultHandler(event:ResultEvent):void {
         ta.text += "Server responded: "+ event.result + "\n";
     }
     // Handle a message fault.
     private function faultHandler(event:FaultEvent):void {
         ta.text += "Received fault: " + event.fault + "\n";
     }
     
    ]]>
    </mx:Script>
    <mx:RemoteObject id="remoteObject" destination="echoServiceDestination" result="resultHandler(event);" fault="faultHandler(event);"/>
    <mx:Label text="Enter a text for the server to echo"/>
    <mx:TextInput id="ti" text="Hello World!"/>
    <mx:Button label="Send" click="echo();"/>
    <mx:TextArea id="ta" width="100%" height="100%"/>
    </mx:Application>

    Compile the client application into a SWF file by using Flex Builder or the mxmlc compiler, and then deploy it to
    your web application.
     

    posted on 2011-06-29 11:09 Eric_jiang 閱讀(232) 評(píng)論(0)  編輯  收藏 所屬分類: Flex
    主站蜘蛛池模板: 天天拍拍天天爽免费视频| 亚洲真人日本在线| 久久精品国产亚洲av高清漫画| 国产成人精品久久亚洲高清不卡| 成人黄网站片免费视频 | 精品国产无限资源免费观看| 亚洲色婷婷综合开心网| 国产精品亚洲片夜色在线| 高清一区二区三区免费视频| 亚洲国产精品视频| 亚洲熟伦熟女专区hd高清| 91福利免费视频| 久久亚洲国产成人影院网站| 久久久久久亚洲精品无码| 91麻豆最新在线人成免费观看 | 一级毛片视频免费观看| 成年女人免费视频播放体验区| 亚洲国产精品久久| 美女无遮挡拍拍拍免费视频| 免费人成在线观看播放国产| 一本色道久久88亚洲精品综合 | 国产高清视频在线免费观看| 亚洲午夜成激人情在线影院| 一区二区三区无码视频免费福利| 亚洲第一永久AV网站久久精品男人的天堂AV| 亚洲免费观看在线视频| 久久不见久久见免费视频7 | 久久久久亚洲Av无码专| 日韩av无码免费播放| 国产精品V亚洲精品V日韩精品| 亚洲AV成人一区二区三区观看| 男男AV纯肉无码免费播放无码| 亚洲综合一区二区精品久久| 亚洲免费精彩视频在线观看| 久久亚洲国产午夜精品理论片 | 精品一区二区三区免费毛片爱 | 亚洲黄色在线观看网站| 日本免费污片中国特一级| 亚洲精品国产精品乱码在线观看| 精品多毛少妇人妻AV免费久久| 亚洲国产综合无码一区二区二三区 |