使用Flex和Grails快速的創(chuàng)建Hello World

          1. grails create-app myproject (創(chuàng)建名為myproject的grails應(yīng)用工程)

          2. grails install-plugin flex (安裝grails的flex插件,首次安裝的話會(huì)比較慢,因?yàn)闀?huì)下載很多Flex和BlazeDS的jar文件)

          3. grails create-service Hello (生成一個(gè)HelloService.groovy, 在grails-app/services目錄下), 編輯該文件:
             1class HelloService {  
             
          2.   
             
          3.     static expose = ['flex-remoting']  
             
          4.   
             
          5.     boolean transactional = true  
             
          6.    
             
          7.     def hello() {  
             
          8.         return "Hello,world!"  
             
          9.     }  
            
          10.   
            
          11. }             


          4. 編寫flex客戶端, 比如main.mxml:
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

          <mx:RemoteObject id="ro" destination="helloService"/>

          <mx:Button label="Hello" click="ro.hello()"/> <mx:TextInput text="{ro.hello.lastResult}"/>

          </mx:Application>

          5. 使用grails run-app 啟動(dòng)服務(wù)器
          6. 訪問http://localhost:8080/sample/bin/sample.mxml,或者h(yuǎn)ttp://localhost:8080/sample/bin/sample.html
             點(diǎn)擊“Hello”,就可以顯示Hello world了

          注意:如果無法訪問編譯sample.mxml生成的sample.html,則需要指定兩個(gè)參數(shù)
           1) 指定-services參數(shù)為web-app/WEB-INF/flex/services-config.xml(相對或絕對路徑都可),
           2) 指定-context-root參數(shù)為web的context,如本例中為sample

          posted on 2008-07-16 22:35 想飛就飛 閱讀(634) 評論(1)  編輯  收藏 所屬分類: FlexGroovy/Grails

          評論

          # re: 使用Flex和Grails快速的創(chuàng)建Hello World [未登錄] 2008-07-24 17:27 javaread.com

          推薦國內(nèi)第一個(gè)基于Grails開發(fā)的Java&Grails技術(shù)網(wǎng)站www.javaread.com。  回復(fù)  更多評論   

          公告


          導(dǎo)航

          <2008年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          統(tǒng)計(jì)

          常用鏈接

          留言簿(13)

          我參與的團(tuán)隊(duì)

          隨筆分類(69)

          隨筆檔案(68)

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 广河县| 瓦房店市| 聊城市| 洛浦县| 高清| 弋阳县| 石棉县| 依安县| 肇庆市| 托克逊县| 东平县| 尼木县| 合阳县| 天气| 怀安县| 秦皇岛市| 辉县市| 田阳县| 枣庄市| 保康县| 孟津县| 上饶县| 延寿县| 堆龙德庆县| 临夏县| 应用必备| 威信县| 老河口市| 梅河口市| 巴塘县| 鹤壁市| 科技| 凤阳县| 永和县| 蓝山县| 屏东县| 土默特右旗| 中江县| 台中市| 辽源市| 庄河市|