December 08, 2006

Customize Dojo ComboBox

 

This post shows some tips that I found to customize the dojo ComboBox Widget.

1. Change text align in drowdown menu:
Change dojoComboBoxOptions in dojo/src/widget/ComboBox.css

/* the drop down */
.dojoComboBoxOptions {
font-family: Verdana, Helvetica, Garamond, sans-serif;
/* font-size: 0.7em; */
background-color: white;
border: 1px solid #afafaf;
position: absolute;
z-index: 1000;
overflow: auto;
cursor: default;
text-align: left;
}

Read more : 0 responses : Friday, December 08, 2006

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

Read more : 1 responses : Thursday, December 07, 2006

December 03, 2006

How to get Servlet context in Struts Action class ?

 

English

In a servlet, to get the Servlet context, you use

ServletContext context = getServletConfig().getServletContext();
In a Struts Action class, you need to get the Servlet first. Then you can get Servlet context

ServletContext context = getServlet().getServletConfig().getServletContext();



Vietnamese

Trong một servlet thông thường, để lấy Servlet context bạn sử dụng đoạn code sau:

ServletContext context = getServletConfig().getServletContext();

Nhưng trong một Struts Action class, bạn cần phải lấy Servlet trước. Khi đã có Servlet rồi, bạn sử dụng bình thường như ở trên
ServletContext context = getServlet().getServletConfig().getServletContext();

Read more : 0 responses : Sunday, December 03, 2006