• Enter Slide 1 Title Here

    This is slide 1 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

  • Enter Slide 2 Title Here

    This is slide 2 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

  • Enter Slide 3 Title Here

    This is slide 3 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

Wednesday, August 29, 2007

Add css styles for gwt widgets

Adding Cascading styles (CSS) to Google Web Toolkit (GWT) widgets is much simpler and involves only two steps.
  1. Style name
    • set style name
      for a widget using the $widgetInstance$.setStyleName() method or
    • stick with the default
      style name of the widget (use for setting global values)
      default style name examples:
      • for buttons: .gwt-Button
      • for Check Boxs: .gwt-CheckBox

  2. CSS style rule
    • Add CSS style rules to a .css file and import that into the html page or

    • write those inside the html page itself. (not recommended)

Let us provide you with an example which would create buttons shown below.


Coding in your java class:
Button cancelButton = new Button("Cancel");
Button loginButton = new Button("Login");
loginButton.setStyleName("buttons");

CSS rules:
.gwt-button {
background: #EEEEFF;
color: #0000CC;
font-size: 12px;
}

.buttons {
background: #CCCCCC;
color: #333333;
font-size: 12px;
}

GWT releases 1.4 and is no longer beta

Google Web Toolkit (GWT) has released a new version, 1.4. With over 1 million downloads GWT is moving forward well; and it's no longer beta. The user group is really active and well established; so if you haven't tried GWT yet, it's time to have a look.

GWT LogoRead more about GWT and news release at GWT blog.

For any issues visit the GWT user group here.

Monday, August 27, 2007

Would Google Adsense let a website earn $100,000 per month?

With Google Adsense earning $100,000 per month!!! Feels like day dreaming? Are there web sites earning around 100k dollars per month; shockingly and interestingly the answer is yes. There are some few sites that earn this much; even more than that.

Believe me

A social site named "PlentryOfFish" owned by "Markus" has earned more than $900k in two months while "ShoeMoney" blog earned more than $100k in one month. See the proofs here and here. So the good news is we should try now and reach there since it is possible.

Analysis of sites earning with Adsense

  • Monthly visitors
    Number of visitors is a huge factor considering the Adsense revenue as visitors help revenue increase; so having a healthy visitors base is a must.

  • Adsense ads placement
    Many sites have been using text/image advertisements rather than going for text only ads or image only ads to change what user sees at first. Adsense text only ads are placed before/inside/after articles; but 250x250 / 300x250 ad formats are mainly used inside articles which would attract reads attention easily and quickly. Also one more point to note is the placement of 160x600 wide Skyscraper advertisements on to left or right bar running parallel to article content. Google Adsense Ad units are not much seen. One important point to note is the color matching of the ads with site content.

How can you reach there

Since every website or blog is unique, suitable adsense ad type, colors, sizes and places differ from each other; also whether to choose image only/text only or text and image also differ. Must choose between rounded corners(LINK) or not; depending on used web template. Best approach is to experiment many combinations of these and decide the best matching format. Adsense channels become handy in testing ads; as each ad placement can be assigned a unique channel which ease the experimenting and lead to accurate decisions. As an example; one channel may be named "leftBar.468x60.Pal3.21092007"; as the name suggests all features of used format, analysis would be really easy. Between one to two months will be enough to judge one advertisement format.

While experimenting for best Adsense ad formats, one important point to note is " publishing valuable contents frequently is a must".

Tuesday, August 21, 2007

Adsense Ads between blogger posts

If you have switched your blog from older blogger to new blogger platform (which uses layouts) and looking for adding adsense advertisements in between posts; Blogger has created a new widget for this purpose. And they have made it such that any non-tech blogger even can use this. This widget lets you specify number of posts between an adsense advertisement. You can see the full guide here at Get inline.

If you haven't switched to new blogger yet, don't worry. You still can put adsense ads between your posts. You have to put the adsense code inside the tags that shows up the blog post. My home page has done like that. If you need any assistance on that, just drop me a mail or write below as a comment. I would be happy to help you.

Thursday, August 16, 2007

GWT not working on Internet explorer 7 (IE7) giving "Element not found" javascript error

GWT web application started to give "Element not found" javascript error message on Internet Explorer 7 (IE7)? This application worked fine on Internet Explorer 6 and Firefox 2. Now your best guess would be; GWT not working on IE 7 properly. Wasn't it?

But the scenario became confusing and unbelievable because your application worked fine on IE7 in some machines while not on some others. Have you faced this issue? Then the below solution is for you.

This issue can be fixed by a making a change on windows registry.

Steps to follow are;
1. Open up the Registry editor - type regedit on command prompt.

2. Look for the key shown below
HKEY_CLASSES_ROOT\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32

3. Click on the "Default" row and see the value there. If it's value is "C:\WINDOWS\system32\shdocvw.dll", then that is what causes the above mentioned issue. If you have installed Windows in a different drive; C:\ must be replaced with the that letter.

4. Replace that value with "C:\WINDOWS\system32\ieframe.dll".

5. Now restart IE7, and load your GWT application.

Monday, August 13, 2007

Set Cookies with GWT applications to expire after expected time period

Google Web Toolkit (GWT) supports HTTP cookies similar to other web technologies. GWT provides methods for setting cookies for specified time duration, for specific domains and paths. Below is a listing on how to set a basic cookie for a duration of one day.
Date now = new Date();
long nowLong = now.getTime();
nowLong = nowLong + (1000 * 60 * 60 * 24 * 7);//seven days
now.setTime(nowLong);

Cookies.setCookie("sampleCookieName", "sampleCookiValue", now);

When retrieving the cookies, you have to specify only the name of the cookie, nothing related to duration. If the cookie is found in the browser for this domain (not expired); value you set will be returned.
Cookies.getCookie("sampleCookieName");//only name

In setting cookies, you must consider on what you actually plans to get done using a cookie. There are two features you can achieve; remember duration (i)from the day it's created, (ii) from the last day this particular user viewed your site. If your site always set cookies when ever a user visits your site; then your cookies will expire only after the user does not revisit your site for the specified duration. But if you are providing a feature like "Saving the password for 2 weeks", then you probably should store the cookie only if the cookie does not exists. For that you must look for cookie before setting it again.
String sampleValue = Cookies.getCookie("sampleCookieName");
if(sampleValue == null){
//set cookie again after informing user on expiration.}

Monday, July 30, 2007

New Firefox release 2.0.0.6 - Security update

A new version of Firefox, 2.0.0.6 has been released today. This is another security update. And they released the 2.0.0.5 version just 13 days ago. That's why I really love Firefox. When ever an issue is reported, they work on it and provide us with a new version so that we are on the safe side always. And this is not the case with some other browsers where people have to wait months and years for some fixes. So thanks guys for all your dedication on making a better product.

Read the release note for more info.

Thursday, July 19, 2007

Scrollable table with GWT

We came across a requirement to build a scrollable data table using Google Web Toolkit (GWT) because we had a limited space, but a growing table depending on the search criteria. As anyone can guess, having a scrollable table would be the best option. For that we used two components rather than one; com.google.gwt.user.client.ui.ScrollPanel and com.google.gwt.user.client.ui.FlexTable. The data table was added inside the Scrollable Panel.

For clarification, we have added the code below.
ScrollPanel scrollPanel = new ScrollPanel();
FlexTable dataTable = new FlexTable();

dataTable.setWidth("100%");
scrollPanel.add(dataTable);
scrollPanel.setSize("300", "200");

//add data to table
....

For setting width and height; it's advised to use css rules, but for ease of understanding we have shown some hard coded values here.

Thursday, July 12, 2007

Jar not loaded warning/error in Google Web Toolkit (GWT) deployment to tomcat

When a Google Web Toolkit (GWT) web application is deployed to Tomcat web server, you may encounter a warning message as follows.
org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(<$webAppsFolder$>\WEB-INF\lib\gwt-user.jar) - jar not loaded.
See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

No need to worry too much about this warning message. This raises just because WebappClassLoader has loaded the servlet.jar already. The gwt-user.jar already contain the content of the servlet.jar file. Even though this message can be ignored, this warning message can be avoided just by replacing the gwt-user.jar file with gwt-servlet.jar (which comes with Google Web Toolkit (GWT) download).

Following image shows the content of the gwt-user.jar, and the content of the servlet.jar is highlighted.



gwt-servlet.jar has been created by removing the content of the servlet.jar from the gwt-user.jar, so this change will not have any impact on your project.

Thursday, July 5, 2007

Call a javascript function inside body of a web page

JavaScript is mainly used for actions on user events like onClick(), onMouseOver() etc. But what if you need to call a JavaScript function without any user events? Answer would be to use the onLoad() of the body tag.
<body onLoad="javascript:myfunction()" >
But what if you don't have access to change the onLoad()? Is there an answer for that as well?


Yes, and it's easy. Just call the function inside your page as same as you would write JavaScript inside the body of a page.
<script type="text/javascript" language="JavaScript">
doSomething('params');
</script>

In this example, doSomething() function is added to the web page inside the header of the page. And for ease of understanding the complete code is shown below.
<html>
<head>
<script type="text/javascript" language="JavaScript">
function doSomething(params);
//do something nice with params
}
</script>
</head>

<body>
This page does call a JavaScript function when the page is loaded,
without using the onload() event call.

<script type="text/javascript" language="JavaScript">
doSomething('blue');
</script>
</body>
</html>

Wednesday, July 4, 2007

[Cricket] Sangakkara joins the "five double hundreds" club

Today Kumara Sangakkara become the seventh cricketer to reach five double hundreds in Test. This is a real achievement and it shows Sangakkara's patiences as well as the talents. Sri Lanka is the only country to have more than one player in that list of seven players.

Here are the seven players with five or more double hundreds.

1. Donald Bradman (AUS)- 12
2. Brian Lara (WI) - 9
3. Wally Hammond (ENG) - 7
4. Marvan Atapattu (SL) - 6
5. Javed Miandad (PAK) - 6
6. Kumara Sangakkara (SL) - 5
7. Rahul Dravid (IND) - 5


Well done Sanga.