Now I own the full deck of the Microsoft certifications and I can sit back and relax (beer is in order . Unfortunately, in the startup world that I operate most of the time, it’s not very recognizable achievement, but it’s nice to put these logos on my presentation slide decks and, especially now, I have a very powerful bragging rights – I have ALL of the Microsoft developers certifications !!!
It was a lengthy path and, I should add, a very confusing one. It wasn’t very obvious what certification is a prerequisite to which one and, I must add, I’ve made a couple of mistakes on the road until I’ve discovered a developer’s certification map by Jorgen Thelin that put everything in order and cleared all the confusions.
Note that the watermark style can contain images as well (see the commented out piece).
After the styles were defined we need to add some code that will apply it to the text box. To do this I’m going to extend the default GWT TextBox. The trick is to hijack the OnBlur and OnFocus events. When the OnBlur is occurring, we’re going to show the watermark and OnFocus – hide it:
public class WatermarkedTextBox extends TextBox implements BlurHandler, FocusHandler
{
String watermark;
HandlerRegistration blurHandler;
HandlerRegistration focusHandler;
public WatermarkedTextBox( )
{
super();
this.setStylePrimaryName("textInput");
}
public WatermarkedTextBox(String defaultValue)
{
this();
setText(defaultValue);
}
public WatermarkedTextBox(String defaultValue, String watermark)
{
this(defaultValue);
setWatermark(watermark);
}
/**
* Adds a watermark if the parameter is not NULL or EMPTY
*
* @param watermark
*/
public void setWatermark(final String watermark)
{
this.watermark = watermark;
if ((watermark != null) && (watermark != ""))
{
blurHandler = addBlurHandler(this);
focusHandler = addFocusHandler(this);
EnableWatermark();
}
else
{
// Remove handlers
blurHandler.removeHandler();
focusHandler.removeHandler();
}
}
@Override
public void onBlur(BlurEvent event)
{
EnableWatermark();
}
void EnableWatermark()
{
String text = getText();
if ((text.length() == 0) || (text.equalsIgnoreCase(watermark)))
{
// Show watermark
setText(watermark);
addStyleDependentName("watermark");
}
}
@Override
public void onFocus(FocusEvent event)
{
removeStyleDependentName("watermark");
if (getText().equalsIgnoreCase(watermark))
{
// Hide watermark
setText("");
}
}
}
After months of working (mainly fighting with quirks of Java) with GWT I’ve accumulated so much knowledge on the topic so, I feel, it starts spilling over. I’m planning to convert this spill into a series of articles on how to build fat REST-full GWT web fat clients both on Java and .NET.
Here is the list of topics I’ll cover:
Building GWT fat client
Java REST-full Web services
.NET REST-full Web services
Internationalization and localization
IOC/DI
Unit testing and integration testing of all the components of the system
Build automation
and much, much more …
Here is a draft list of technologies I’ll be using:
GWT
Eclipse
Spring
Jersey
Tomcat
XStream
AJAX
JSON/XML
WCF
JUnit/TestND/NUnit
Selenium
Ant
TeamCity
and much, much more …
For starters, let’s see how to create a simple GWT fat client that talks to the REST-full Web services. As an example,
Last Wednesday John Resig stopped by to chat about jQuery. The room was packed so we had to join a second room. It was a pretty engaging presentation – loved it.
And finally loved the Google trends chart of the adoption rates of all the major java script libraries that John mentioned (link is under the picture):