twitter

java

triggering native events in GWT

In GWT, to fire an event on an element and trigger your change handlers you may have setup do:
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), inclusionCriteriaSelect);
This way, any UI logic you've set up on form elements that are event driven can be reused.
read more...
under: java

cognitive dissonance in java

It seems to me unintuitive to have things floating around = to null but able to call methods. for example:
class Foo{ 
static void doStuff(){ } 
}
Foo foo = null;
foo.doStuff(); //works
The fact that though foo is null and is invoking a static method makes sense when carefully considered, but reduces the clarity of code when trying to understand large amounts of it at once.. this leads to increasing confusion as the system becomes more complex! This gets even more confusing when the relationship between the Type of null and the relationship of its static methods becomes more complex. for example:
 public class Foo {
   static int fubar = 42;
   Foo getFoo() {
     return null; 
   }
   public static void main(String args[]) {
   Foo foo = new Foo();
   System.out.println(foo.getFoo().fubar);
  }
}
// output : 42
c# on the other hand takes the approach of disallowing the calling of static methods on class instances. this intuitively seems easier to understand.
Update - Eclipse can be configured to trigger warnings for "indirect access to static members" under Java > Compiler > Errors/Warnings.
read more...
under: java

Changing the Start day of the week on GWT's DateBox/DatePicker widget

If you've run into an issue where GWT loads the DateBox component and incorrectly sets the start day to something strange (I was getting Monday, rather than the correct Sunday start day), the problem is a bit vexing and the solution isn't obvious at first. There's no way to change the start using the DateBox api - instead, it's actually tied to the application's il8n/locale settings.
read more...
under: java

Categories

rss feed