click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From WarnerJan Veldhuis <warnerjan.veldh...@qprcostcontrol.com>
Subject I18N in forms
Date Thu, 31 Dec 2009 10:58:01 GMT
It might be worth mentioning in the docs that when subclassing forms and 
using i18n, you should place control creation in onInit(), instead of 
the constructor.

This example will not use i18n, since getMessage() does not have a 
parent context:

public class LoginForm extends Form {
     public *LoginForm()* {
         TextField username = new TextField("username", 
getMessage("label_username"), true);
         add(username);
     }
}

This example works with i18n, at least, using onInit() is how I solved 
this issue:

public class LoginForm extends Form {
     public LoginForm() {
     }

     public *onInit()* {
         TextField username = new TextField("username", 
getMessage("label_username"), true);
         add(username);
     }
}

Is this assumption correct?

Cheers,

WarnerJan

Mime
View raw message