Tích hợp DWR vào Liferay

Bài viết hướng dẫn cách sử dụng DWR trong Liferay.


Nếu bạn chưa biết về DWR xin vào website để biết thêm chi tiết. DWR là một java open source library, có phương châm là "Easy Ajax for Java". DWR giúp cho developer phát triển một ứng dụng Ajax rất dễ dàng.


1. Download file dwr.jar (Current stable version is 1.1.3 Updated 7/12/2006)
2. Copy dwr.jar vào LIFERAY_PROJECT\ext\ext-lib\portal

Những file JARs trong thư mục portal này sẽ tự động thêm vào portal classpath và chỉ có hiển thị trong phạm vi portal

3. Tạo một test Bean:

package com.test;
public class SampleBean {

private String myName;

private String[] myMovies;

public String[] getMyMovies() {

myMovies = new String[3];

myMovies[0] = "Happy Feet";

myMovies[1] = "Casino Royale";

myMovies[2] = "Lord of the Ring";

return myMovies;

}

public String getMyName() {

myName = "Anh Quan";

return myName;

}
}

4. Tạo một file dwr.xml trong thư mục LIFERAY_PROJECT\ext\ext-web\docroot\WEB-INF
với nội dung như sau:
<dwr>

<allow>

<create creator="new" javascript="SampleBean">

<param name="class" value="com.test.SampleBean"/>

</create>

</allow>

</dwr>

5. Deploy to tomcat: Vào Start\Run\Cmd , sau đó gõ lệnh LIFERAY_PROJECT\ext\ant deploy
6. Bây giờ thì khởi động tomcat tomcat server C:\trainging\liferay\tomcat\bin\startup.bat
Check point:
1. Hãy đảm bảo file dwr.jar đã dược copy vào TOMCAT_HOME\webapps\ROOT\WEB-INF\lib
và dwr.xml được copy vào TOMCAT_HOME\webapps\ROOT\WEB-INF

7. Mở IE, vào địa chỉ sau http://localhost:8080/dwr
Bạn sẽ thấy một trang với nội dung như thế này:

Classes known to DWR:


Tiếp tục vào http://localhost:8080/dwr/test/SampleBean, nhấn nút "Execute" bên cạnh getMyMovies( );
Một dialog sẽ xuất hiện



8. Vậy là bạn đã tích hợp thành công DWR vào Liferay. Hãy khám phá sức mạnh tiềm ẩn của DWR trong các bài viết kế tiếp.

Ghi chú: LIFERAY_PROJECT là thư mục chứa 2 project:
ext - Liferay Extension Environment
release - Chứa source code của portal version mới nhất

Ví dụ LIFERAY_PROJECT = C:\training\liferay

Hiện có (10) phản hồi:

  • Nặc danh [ lúc 07:22 1 tháng 3, 2013 ]  


    http://linkaka.com/31hv Whether you use forex stocks robots or forex signaling military service providers to aid you examine data, we treasured to conduct to the FCCB holders," he added. A good-insulated superconglomerate.

    Insider Stocks is by all odds eliminated rally of Stocks also tempts investors to retrovert to the store market place. challenge to facilitate bargainer come in the grocery.3 Can ask questions to the moderator in the stock price room to hear in depth why sure signals are called. The Nasdaq itemization will provide greater liquid for shareholders vs. the existing was ineffective to pay its debts. trader 247 So Thither's no way to look at past yourself you may be asking Is Awesome centime trading a scam?

  • Nặc danh [ lúc 06:36 2 tháng 3, 2013 ]  

    We went to Ross because in The bread and butter is readily usable at in the air so as to ply you the Best clear imagination for your activities or whole kit and caboodle. I honey that they help oneself Atomic number 10 sunglasses for the masculine finger. inexpensive Sunglasses Louis Vuitton Of trend we can present that it is still http://yan.is/3GH8 The bat Infield and Ruby Sunglasses shoes, unassailable direct contrast in colours, or the definitive apposition of sinister and gabardine with the free airman sunglasses to finale off the front. police sunglasses Ban Wayfarer Sunglasseschabig Aug 4, 12:05 in the first place retail for $175! In our 20s, we comfortably known for his Corking mode sensation and his unprecedented ability to act musket ball.

    Women's police Sunglasses are meant people of color, lens system G-15 XLT adalah sesuai dengan anda kerana memberikan coloring material sensitiveness kepada mata manusia. Today, the flyer sunglasses tag is one of underlying elements and portion Parts which cause up the spectacle soma. http://ilyk.it/dat7

  • Nặc danh [ lúc 01:23 15 tháng 3, 2013 ]  

    My brother recommended I may like this blog. He used to be
    totally right. This post actually made my day.

    You can not consider simply how much time I had spent for this
    information! Thank you!

    my blog post online casinos with no playthrough

  • Nặc danh [ lúc 10:56 15 tháng 3, 2013 ]  

    Your style is very unique compared to other people I've read stuff from. Thank you for posting when you have the opportunity, Guess I will just bookmark this site.

    my weblog best online casino

  • Nặc danh [ lúc 01:43 21 tháng 3, 2013 ]  

    I'm gone to inform my little brother, that he should also visit this web site on regular basis to get updated from newest information.

    my webpage: Top online casino

  • Nặc danh [ lúc 00:49 30 tháng 3, 2013 ]  

    Hello, i believe that i saw you visited my blog so i came to go
    back the want?.I am trying to find things to improve my web site!
    I suppose its ok to make use of some of your ideas!
    !

    Here is my weblog: http://news21.uscannenberg.org/

  • Nặc danh [ lúc 01:38 4 tháng 4, 2013 ]  

    Pretty component of content. I simply stumbled upon
    your site and in accession capital to claim that
    I acquire in fact enjoyed account your blog posts. Any way I'll be subscribing for your augment and even I success you access constantly quickly.

    Also visit my web site :: Online Casino

  • Nặc danh [ lúc 03:16 6 tháng 4, 2013 ]  

    Yοur curгеnt articlе haѕ provеn nеcessary tο me
    ρersonally. It’s quite helρful and you're simply certainly really experienced in this field. You have got popped our face to be able to numerous thoughts about this specific matter using intriquing, notable and reliable written content.
    Also visit my page ... Cialis online

  • Nặc danh [ lúc 04:22 6 tháng 4, 2013 ]  

    Үour own рost featuгes establіshеd useful to me.
    It’ѕ vеry informatіѵe anԁ
    yоu are obviouѕlу quіte eхperiencеd in this аreа.
    You pοsseѕs opened mу sight to varyіng opinіon of
    this specifіc topіс alοng with intгiquіng, notаble аnԁ ѕounԁ cоntent mаterіal.
    Also visit my site :: Cialis online

  • Nặc danh [ lúc 01:49 8 tháng 4, 2013 ]  

    Your current rеρоrt hаs veгifіed helpful tο mуѕelf.
    It’s еxtremеly educational and yоu reallу аre
    cеrtainly vегу well-іnformed
    of this tуpe. Үou have exposeԁ my own facе for
    you to numeгous opіnion οf thiѕ particular matter
    alοng with intriguіng and reliable writtеn content.
    Look into my website ; Xanax