Friday, May 22, 2009

Firefox Sucking Up Your Memory?

THis is a good article to read on how to tune your Firefox: http://stayupdate.com/tips-tricks/increase-firefox-speed-and-decrease-firefox-memory-usage-20-tips/567

Wednesday, May 20, 2009

Divide 0 by 0

Here's a simple algo to divide 0.0 by 0.0:

double a = 0.0 / 0.0;
double b = 1.0 / 0.0;
double c = 0.0 / 1.0;
double d = 1.0 / 1.0;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);

Here are the results:

NaN
Infinity
0.0
1.0


Good reference: http://www.math.utah.edu/~pa/math/0by0.html

Monday, May 4, 2009

Getting the rendered height of a html body tag

I came across this problem the other day.

I have a html page with a couple of divs in the body tag. My divs had lengthy text and images. Hence, when I made the border of page visible (by setting the border style of the body tag), the border encaptulated all the divs and was visible when i scrolled down.

When I then included a div that had a background image that I wanted to repeat vertically, this image only got repeated to the height of my screen (i.e. when I scrolled to the bottom of the page, I could see that the image did not get rendered all the way to the bottom). I used height = 100% for the style of this div.

After poking around, I realised that the height=100% means that the div (containing the vertical image) only had a height that was equivalent to the height of the visible screen. To get the FULL height of the body, I had to use this function, called from the body's onLoad event:

function borderheight()
{
var leftborder = parent.document.getElementById('leftborder');
leftborder.style.height = document.body.clientHeight + "px";

var rightborder = parent.document.getElementById('rightborder');
rightborder.style.height = document.body.clientHeight + "px";
}


Hope using clientHeight helps all of you who come across this problem.

GWT-EXT error: com.google.gwt.core.client.JavaScriptException: (TypeError): '$wnd.Ext.StatusBar' is null or not an object

The reason why you are getting this error is most probably because you have not installed ext and included the ext.jar file in your build path. Hence, you have a ext wrapper classes (eg. Gwt-Ext) but not EXT itself.

First of all, download EXT 2.0.2 from http://yogurtearl.com/ext-2.0.2.zip (link can be seen in http://code.google.com/p/gwt-ext/)

Then, add the ext-base.js, ext-all.js and ext-core.js files into the public folder of you GWT project. (eg. in com.redflex.gwt.public.js)

Then, define these in your project's html file:
< !--include the Ext CSS-- >
< link rel="stylesheet" type="text/css" href="js/ext/ext-all.css" / >

< !--include the Ext Core API-- >
< script type="text/javascript" src="js/ext/adapter/ext/ext-base.js" >< / script >


< !--include Ext -- >
< script type="text/javascript" src="js/ext/ext-all.js" > < / script >


This provides access to Ext's Javascript functions which resolves the " '$wnd.Ext.StatusBar' is null or not an object" error.


Make sure your paths to the ext-base.js, ext-all.js and ext-core.js files are correct into you < script > tags.

You can also copy all the other css files in the resources folder of Ext 2.0.2. This will allow your widgets to look like the ones shown in http://code.google.com/p/gwt-ext/

GWT-EXT Error: Scanning source for uses of the deprecated gwt.typeArgs javadoc annotation; please use Java parameterized types instead

So I downloaded GWT-EXT 2.0.6 and placed it in my Eclipse project's build path. Then I wrote some simple code:
MapPanel osm = new OpenStreetMap();

Then i placed this in my project's the gwt.xml file



When I ran this code in hosted mode, I got this error:

[DEBUG] Scanning source for uses of the deprecated gwt.typeArgs javadoc annotation; please use Java parameterized types instead
[DEBUG] Type com.gwtext.client.data.NodeModel
[TRACE] Field attributesAllowed
[WARN] Deprecated use of gwt.typeArgs for field attributesAllowed; Please use java.util.ArrayList as the field's type
[TRACE] Field children
[WARN] Deprecated use of gwt.typeArgs for field children; Please use java.util.ArrayList as the field's type
[TRACE] Field properties
[WARN] Deprecated use of gwt.typeArgs for field properties; Please use java.util.HashMap as the field's type

I have GWT 1.5.3.

I scanned forums which all said that the reason for this is because GWT 1.5 uses generics rather than the @gwt.typeArgs annotation. (eg: http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/74037cd1bc9c85d0)

However, I did not use any annotations. Hence, this did not resolve my problem.

I then found out that this was a bug and it was fixed here:
http://code.google.com/p/gwt-ext/issues/detail?id=464

Download the jar file in the above URL. Use that jar file instead. You won't get the error anymore.

Version of Ext in use not compatible with GWT-Ext.

When I ran my GWT application in hosted mode, I kept getting the following error:

Version of Ext in use not compatible with GWT-Ext.
GWT-Ext only supports Ext v.2.0.2.


I was already using EXT 2.0.2 (from http://yogurtearl.com/ext-2.0.2.zip) on GWT-EXT 2.0.6 (http://gwt-ext.com/download/) and I put the ext-all.css, ext-all.js and ext-base.js files into a local js folder so that my html file could access them using this:

< ! --include the Ext CSS -- >
< link rel="stylesheet" type="text/css" href="js/ext/ext-all.css"/ >

< !--include the Ext Core API-- >
< script type="text/javascript" src="js/ext/adapter/ext/ext-base.js" >< / script >


< !--include Ext -- >
< script type="text/javascript" src="js/ext/ext-all.js" >< / script >


The way I solved this was to clear my IE browser cache. In Windows, the hosted mode uses IE.

Friday, May 1, 2009

Changing Subclipse's Username and Password

This blog provides indepth information on how to change your subclipse username and password:
http://shahjapan.blogspot.com/2008/08/how-to-clear-subeclipse-password-svn.html