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?

AdvertisementAmazon.com Textbooks

Tuesday, August 28, 2007

5 ways to speedup javascript

From http://www.whenpenguinsattack.com/2007/08/20/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."

example:

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

alert(x1+x2);
}

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;
}



http://www.whenpenguinsattack.com/2007/08/20/5-ways-to-speedup-javascript/

AdvAmazon.com 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.


http://www.informit.com/guides/printerfriendly.aspx?g=java&seqNum=363


Using Ajax across multiple domains

From http://www.whenpenguinsattack.com/2007/08/13/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.

Example

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();

http.open("POST"."http://www.yahoo.com/service");
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 http://www.yahoo.com/service [P]

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

Replace the above line: (http.open("POST"."http://www.yahoo.com/service")) with

http.open("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.

http://www.whenpenguinsattack.com/2007/08/13/using-ajax-across-multiple-domains/

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 Javaworld.com 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
Javaworld.com

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 ==> http://www.humfm.com/humfm.asx

AajKal - Asian Network ==> http://stream.servstream.com/ViewWeb/BBCRadio_music/Event/BBCAsianNetwork_hi.asx

Amrit Bani - UK ==> http://62.25.97.192/amritbani?MSWMExt=.asf

ApnaRadio - USA ==> http://www.apnaradio.com/live/media24/ApnaRadio.asx

Asian Gold Radio - UK ==> http://62.25.96.7/asiangold

Asian Sound Radio - UK ==> http://www.vtuner.com/vtunerweb/mms/mms15278.asx

BBC News ==> http://www.bbc.co.uk/worldservice/meta/tx/nb/live_news_au_nb.asx

BombayBeats FM ==> http://www.1.fm/player/energybbfm32k.asx

City 101.6 FM - Dubai ==> http://asx.abacast.com/arabian_radio-city-24.asx

DDLive Video - India ==> http://164.100.51.209/ddlive?MSWMExt=.asf

DesiSoundz - India ==> http://desisoundz.com:8000

Haagstad Radio - Holand ==> mms://81.205.146.32:21/haagstadradio

kismatradio.com ==> http://www.kismatradio.com/newmedia/live.asx

nimboodamusic.com ==> http://www.nimboodamusic.com/nim128.wax

Punjabi Radio - UK ==> http://azul.streamguys.com/panjabradio?MSWMExt=.asf

Radio Apni Awaz ==> mms://67.15.80.29/radioapniawaz

Radio India - Canada ==> mms://live.radioindiabroadcasting.com/liveradio

Radio XL - UK ==> http://www.vtuner.com/vTunerweb/mms/m3u13219.m3u

RadioOfIndia - Bhajans ==> http://www.radioofindia.com/asf/bhajans.asx

RadioOfIndia - Bollywood ==> http://www.radioofindia.com/asf/bollywood.asx

RadioOfIndia - Classical ==> http://66.238.65.109/classical

RadioTarana-NewZealand ==> mms://l1.r2.co.nz/tarana-1

RadioTeenTaal - Paris ==> http://www.radioteentaal.com/masala128.wax

Sabras radio - UK ==> http://ct1.fast-serv.com:8744

Sanskar Radio - UK ==> http://www.vtuner.com/vTunerweb/mms/m3u18290.m3u

Sunrise FM - UK ==> http://62.25.96.7/sunrise

Trishul 90.5 FM ==> http://www.vtuner.com/vtunerweb/mms/mms14734.asx

Yarr Radio - UK ==> mms://193.218.160.20/yaarradio



A

Popular Posts (Last 30 days)

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