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

December 02, 2006

About me

 

My name is Anh Quan Nguyen, from Saigon, Vietnam.
I am currently living in Frankfurt, Germany.

I like to blog about Web 2.0, JasperReports, Portal/Portlet, JSR168, DWR, Dojo, Struts... and so on.

A little bit about my background. In March 2003, I graduated Bachelor in Electronics, Hochiminh City University of Technology. Then I got a position as Electronic Engineer in Sony. Tivi production made me tired. I decided to change my career. In September 2004, I came to Germany to take the Master Course in Communication and Media Engineering. Here I also do not know exactly my real way, become a telecom. engineer or a software developer. After a while of listening to my heart, I know I have no other choice than to become a programmer. It's quite a little bit late, but it's better than going to the wrong way for the rest of my life.

Thank you for visiting my website. And if you are professional programmer, please help me with your knowledge.

Nice to know you all !

Read more : 0 responses : Saturday, December 02, 2006

OutOfMemory - How to avoid it ?

 

Sometimes, you encounter the OutOfMemoryException because JasperReports tries to fill data which are bigger than memory allocated to JVM.
Don't be panic. JasperReports can split a big report to smaller segments and store these segment in a temporary directory in your drive.

What you have to do is to set the built-in parameter REPORT_VIRTUALIZER
Take a look at the code below:

//Create connection to database server
connection = ConnectionPool.getConnection();

//Create a cache at C:\Temp

JRFileVirtualizer fileVirtualizer = new JRFileVirtualizer(3, "c:\\Temp");

//Set parameter REPORT_VIRTUALIZER
HashMap parameterMap = new HashMap();
parameterMap.put(JRParameter.REPORT_VIRTUALIZER, fileVirtualizer);

//Fill data as usual
JasperFillManager.fillReportToFile("MyReport.jasper", parameterMap,connection);



Good luck !

Read more : 0 responses : Saturday, December 02, 2006