Eclipse rap 富用戶端開發總結(15) -rap如何使用js

來源:互聯網
上載者:User
註: Eclipse rap 富用戶端開發總結-系列文章是從本人   Iteye部落格中移植過來.後續會直接在此更新     http://jlins.iteye.com/

1. 把輸入的字串當 javascript 執行

 

try {     RWT.getResponse().getWriter().println("alert('123');"); } catch (IOException ex) {     ex.printStackTrace(); }

2 .通過擴充點增加 js 檔案的方法:

增加:org.eclipse.rap.ui.resources 擴充點

 

然後在resources 擴充點上建立resource :

然後建立resource 擴充類:

 

類:

public class TestResource implements IResource {    @Override    public String getCharset() {        return "ISO-8859-1";    }        @Override    public RegisterOptions getOptions() {        return RegisterOptions.VERSION;    }        @Overridepublic String getLocation() {//js路徑,會在workspace\.metadata\.plugins\org.eclipse.rap.ui.launch\RAPApplication\.metadata\.plugins\org.eclipse.rap.ui\context\rwt-resources\telecomui\js路徑下產生test.js檔案,供我們使用。例如:test.js中有個方法:Function a(){Alert(“aaaaa”);}在代碼中的任何一個方法中只要調用如下代碼就能使用:RWT.getResponse().getWriter().println("a();");        return "telecomui/js/test.js";    }        @Override    public boolean isJSLibrary() {        return true;    }        @Override    public ClassLoader getLoader() {        return this.getClass().getClassLoader();    }        @Override    public boolean isExternal() {        return false;    }}

3.rap 的 js 架構採用的是: qooxdoo

qooxdoo 是一個開源的綜合性 Ajax 架構,是遵守 LGPL 、或 EPL ( Eclipse Public License )許可的,可以用於商業項目,利於它可以建立物件導向的 js 類,也可以開發富用戶端的介面,甚至在網頁上開發出單機程式那樣的介面,是一個不錯的 Ajax 架構。

以前一直使用 Eclipse RCP 進行開發,自從接觸了 Eclipse RAP 後,對 AJAX 產生了興趣,還有未來的 Eclipse 4.0  將會採用Web 架構開發,以後可以在瀏覽器中運行 Eclipse 了,所以想研究研究 AJAX 架構, RAP 的底層是用 Qooxdoo 實現,關於 Qooxdoo ,好像名聲明顯沒有其他架構那麼有名,不過 Qooxdoo 的確是一個非常優秀的 AJAX 架構,關於 Qooxdoo ,你可以從它的首頁上瞭解更多: http://qooxdoo.org/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.