Wednesday, August 29, 2007

Replacing DisplayTag

I have been involved in an Intranet application for a big SCM client for around 2 years now. This application is being build on JBoss with Struts 1.1. Since the days of its prototype, DisplayTag has been used for the Grid type functionality. There are a couple of screens which require Grid. Some of the Grids are editable as well. Moreover, there are various complex scenarios attached with them e.g. pressing escape should bring revert the changes done to selected row or tabbing off the row should result in saving of the row among others.
However, now, we are replacing Display Tag with a Grid Applet. The reason being that it is slow to render pages (through pagination).
So, do you have a view here. Any suggestions which applets can be considered? Textbooks

Tuesday, August 28, 2007

5 ways to speedup javascript


1) use a compressor
JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation.

2) Minimize the number of .js files
Each .js file reference on a web page means another http request from a client's browser. Although it may decrease the readability/maintainability of your code, it is faster to have one larger .js file than multiple smaller ones.

3) use profiler and timer tools
Firebug offers a suite of profiler and timing tools that allows you to see exactly how long your scripts take to execute and gives you the ability to tweak and optimize them.

4) asynchronize your code
Browsers run Javascript code synchronously. This means that when a <script></script> tag has been found, everything on the page stops until the end script tag has been found. If a script doesn't finish executing within a certain amount of time, then the user gets a warning that says, "A script on this page is taking a long time to complete."


function testfunc(){
var x1="test1";
var x2="test2";


testfunc(); //normal way to execute the function
window.setTimeout(testfunc,0); //asynchronous execution of testfunc()

The setTimeout function takes 2 parameters. The first is the name of the function that will be executed and the second is the number of milliseconds to wait until it is called. Since 0 is used for the second parameter, the function is called immediately (it will be forked in the background and the rest of your page will continue to load). This is useful for functions that take a long time to load.

5) cache DOM variables
Every binding in Javascript is late. This means each time you access a property, variable, or method a look-up is performed. Within the IE DOM, this could mean an extensive search of the element to find the same property over and over again, only to be returned to the JScript engine unchanged from the previous request.

Here is an example of a function that can be optimized:

function buildString(){
var newElement = document.getElementById("myitem");
newElement.innerHTML = ""; // Clear out the previous
newElement.innerHTML += addHeader();
newElement.innerHTML += addBody();

Here is the optimized function:

function buildString() {
var newText = addHeader() + addBody();
document.getElementById("myitem").innerHTML = newText;
} Textbooks

Saturday, August 18, 2007

Reference Guide: HProf

InformIT has published a user guide to HProf, the Java profiling tool from Sun.

Sun includes a profiling tool built into the JVM called HProf that can provide you with method-level response times as well as heap information. The JVM provide various programmatic interfaces that allow you to obtain runtime information, and as of Java 5.0 SE, the newest and least invasive is the Java Virtual Machine Tool Interface(JVMTI), which HProf is based on. HProf can be invoked by providing a command line option when you start your Java application and then it generates a log file as output, which you can either examine manually or programmatically parse. Furthermore, HProf executions can be integrated into a build script in order to generate reports automatically.

Using Ajax across multiple domains


XMLHttpRequest, the main component behind AJAX, does not automatically work across multiple domains. This means that you cannot make a request to an ovject on a domain that is different from the web page’s domain. There is an easy solution to this issue: apache’s mod_rewrite module.


function getXMLHttpObject() {
if (window.XMLHTTPRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
return null;

function handleHTTPResponse() {
if (http.readyState == 4) {
results = http.responseText;

var http = getXMLHttpObject();"POST"."");
http.onreadystatechange = handleHttpResponse;

The above example will fail with both Firefox and Internet Explorer (unless you are running it on a web page located on the yahoo domain). There are other ways to allow cross site ajax. Within Internet Exporer, the default security settings can be changed or a host can be added to the “trusted hosts” list. Firefox, on the other hand, has a concept called signed scripts. Both of these methods will not work for most websites on the Internet. This is because it would involve every user coming to your site adding your page to their trusted host list.

Apache setup
  1. Install apache with both mod_rewrite and proxy enabled.
  2. Create the following rule: RewriteRule ^/yahoo_proxy [P]

Note: The [P] indicates a pass-through proxy.

Replace the above line: ("POST"."")) with"POST"."http://your_host/yahoo_proxy") and a connection will be made to the yahoo domains through your apache server while not violating the security restrictions of IE or Firefox.

Thursday, August 9, 2007

Secret of success

"Sir, What is the secret of your success?" a reporter asked the President of a Bank.

"Two words."

"And, Sir, what are they?"

"Right decisions."

"And how do you make right decisions?"

"One word.'

"And, sir, What is that?"

"Experience. "

"And how do you get Experience?"

"Two words"

"And, Sir, what are they?"

"Wrong decisions ."

Monday, August 6, 2007

12 skills that employers can't say no to

There is an interesting article on titled "12 skills that employers can't say no to"by Mary Brandel, listing skills, some of which are already essential to succeed on-job, some are acquiring that status, and few could acquire that status.
  • Machine learning
  • Mobilizing applications
  • Wireless networking
  • Human-computer interface
  • Project management
  • General networking skills
  • Network convergence technicians
  • Open-source programming
  • Business intelligence systems
  • Embedded security
  • Digital home technology integration
  • .Net, C #, C ++, Java -- with an edge

Sunday, August 5, 2007

Online Hindi Radio Stations

Here is the list of Online Hindi Radio Stations. Copy the URL in your media player and enjoy !!

106.2 HUMFM - UAE ==>

AajKal - Asian Network ==>

Amrit Bani - UK ==>

ApnaRadio - USA ==>

Asian Gold Radio - UK ==>

Asian Sound Radio - UK ==>

BBC News ==>

BombayBeats FM ==>

City 101.6 FM - Dubai ==>

DDLive Video - India ==>

DesiSoundz - India ==>

Haagstad Radio - Holand ==> mms:// ==> ==>

Punjabi Radio - UK ==>

Radio Apni Awaz ==> mms://

Radio India - Canada ==> mms://

Radio XL - UK ==>

RadioOfIndia - Bhajans ==>

RadioOfIndia - Bollywood ==>

RadioOfIndia - Classical ==>

RadioTarana-NewZealand ==> mms://

RadioTeenTaal - Paris ==>

Sabras radio - UK ==>

Sanskar Radio - UK ==>

Sunrise FM - UK ==>

Trishul 90.5 FM ==>

Yarr Radio - UK ==> mms://


Popular Posts (Last 30 days)

This is a personal blog and I do not speak for my employer.