December 07, 2006

How to use DWR in Liferay Portal (Part 1 - Installation)

 

This tutorial shows you how to use DWR in Liferay.

I assume that you already know how to use DWR. If not, please go here: Getting started with DWR

1. Download file dwr.jar (Current stable version is 1.1.3 Updated 7/12/2006)
2. Copy dwr.jar to C:\training\Liferay\ext\ext-lib\portal

JARs in the portal directory are automatically copied to the portal classpath and are only visible by the portal.

3. Create a 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. Store the dwr.xml in C:\training\Liferay\ext\ext-web\docroot\WEB-INF
Here is a sample dwr.xml
<dwr>

<allow>

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

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

</create>

</allow>

</dwr>

5. Deploy to tomcat: Start\Run\Cmd , then C:\trainging\liferay\ext\ant deploy
6. Start your tomcat server C:\trainging\liferay\tomcat\bin\startup.bat
Check point:
1. Be sure that dwr.jar is copied to C:\training\liferay\tomcat\webapps\ROOT\WEB-INF\lib
and dwr.xml is copied to C:\training\liferay\tomcat\webapps\ROOT\WEB-INF

7. In IE, go to http://localhost:8080/dwr
You will see something like :

Classes known to DWR:


Go to http://localhost:8080/dwr/test/SampleBean, click "Execute" next to getMyMovies( );
You will see:



8. Congratulation! You are now ready to explore the power of DWR.

Part 1,2

1 responses:

Mary said...

Hello, How do I get in touch with you? There is no email or contact info listed .. please advise .. thanks .. Mary. Please contact me maryregency at gmail dot com