Pages

Saturday, 25 February 2012

GWT KeyPressHandler doesn't work for your widget? Use KeyDownHandler instead.

If you want to catch the 'Enter' or 'Escape' key press event on your GWT widget (FocusPanel, TextBox, ...) and have tried the KeyPressHandler but not success, try to switch to the KeyDownHandler


outer.addKeyDownHandler(new KeyDownHandler() {     
  public void onKeyDown(KeyDownEvent event) {
    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
      loginButton.click();
    } else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
    cancelButton.click();
    }
  }
});

Monday, 6 February 2012

Hadoop: My first play with HDFS

Meet Hadoop!!!
Finally, I have started to explore the popular, robust and scalable framework for distributed and high parallel computing application. I have a plan to work with Hadoop long time before, but till now, I can experience Hadoop in a serious project. And I will move fast forward from now because Hadoop will hold a important role in my current data processing project :)




Sunday, 5 February 2012

JDO Sample project with DataNucleus 3

/**updating ...*/

In this article, I will write a simple demo program to demonstrate the use of JDO to persist data to database.

This program will show a simple sport store, the products in store are sport clothes, kits, shoes, accessories, ...

So, the database schema here looks simple: we have two types of entity, one for category, and one for product. We also have an one-to-many relation from a product to a list of categories, it means that a product maybe belongs to more than one categories. Also notice that, of  course, in a category, we can have a number of products, but in this simple example, I will not use a many-to-many relation, so the categories don't know anything about product.

We have some prerequisites use in this example:
  1. MySQL 
  2. Data Nucleus 3.0
You can find these components from the pom.xml of this sample project.

Initialize project structure


Write POJOs to leverage JDO, ORM


Data persistent class


Put some UI to manage your store


Conclusion