GWT Mini Pattern: Bare Bones Entry Point Class

Don’t ever let your entry point class do anything. Why? Because the constructor of the entry point class will be called twice. Once when the object is being instantiated so that onModuleLoad can be called, and then once if your code does anything useful in the constructor. You can also have a constructor that does nothing active (XHR, modifying the DOM) in which case it won’t matter that it is called twice (except it will slow down the user’s computer a little bit.)
Here’s an example of how not to do it (sorry for the [lack of] code formatting):

 

public class Display implements EntryPoint {  public void onModuleLoad() {  final RootPanel rootPanel = RootPanel.get(COMPONENT_HOME_ID);  if (rootPanel != null) {  Display fd = new Display();  } }  public Display() { Window.alert("new date: "+new Date()); // more stuff }  // more stuff }

If you were to compile and execute the code above, you'd see two different alerts. Instead you want:

public class DisplayEntry implements EntryPoint {  public void onModuleLoad() {  final RootPanel rootPanel = RootPanel.get(COMPONENT_HOME_ID);  if (rootPanel != null) {  Display fd = new Display();  } }  }  class Display { // or it could be in a separate java file public Display() { Window.alert("new date: "+new Date()); // more stuff }  // more stuff }

You can also get around it by having a no-op no arg constructor (which all EntryPoint classes are required to have) and one that takes arguments that you'll use in your class to do something.

Tested on Windows, GWT 1.4.62.


Useful Tools: Skype

Skype is something that I’m relatively late to the game on, but now I can’t believe I lived without it. I use it as a secondary line for my business.  (I know, I know, next thing you know I’ll be telling y’all that the “internet” is the next big thing.) I have a relatively old plan and get nailed whenever I go over in minutes–35 cents a minute. I am planning to get a new plan and phone sometime soon, but want to make sure I get a great phone, and haven’t had time to comparison shop.

Skype is letting me postpone getting a new phone by letting me use my minutes more effectively. Check out my sweet old phone–a super solid Nokia:

Phone

At first, I only had Skype Out, which let me call people in the US for the measly sum of $6 dollars a month. Just recently, I signed up for Skype In, which is actually less expensive–$24/year, and lets me receive phone calls.
However, I won’t be passing out my new Skype number–I want people to associate me with the same number I’ve had since I first got my cell phone. Instead, I’ll just forward all calls from my phone to my Skype number when I m in front of a computer.

I originally got Skype because of the cost savings, but it also makes me more effective on the phone. With a headset that I bought for $40 a year ago, I can type and talk at the same time, as opposed to using speaker phone and/or craning my neck.

The only thing I use my phone for that Skype doesn’t replace is text messages–I use teleflip.com for that, because it is free.

I haven’t really explored the other features of Skype–computer to computer calls or conference calling–but right now Skype does what I need it to do.


State/survey of GWT widgets

GWT does not provide as near a complete set of widgets with GWT as, say, YUI. It does provide a way to integrate existing javascript widgets, as the gwt-ext and gwt-widget projects do. However, this approach is lacking compared to native GWT widget sets because

  1. They require external javascript source files, which you then have to version and your user has to download (even if you only use some of the code). These files are not subject to the GWT optimization/compilation process.
  2. The JSNI methods used to access the third party widgets can cause trouble when you’re debugging in hosted mode. See one example.

I think it would be worth the GWT team taking more action to standardize the GWT widget set. Yes, the incubator is a start, but some of the widgets there are months old. Among other things, I could not find a carousel component that didn’t depend on kilobytes of external YUI javascript.

Here’s an informal list of GWT widget toolkits that I’ve found in my searches. Most I’ve tried and found useful, some I just have looked at. Some are native, some are wrappers.

  • The GWT incubator: these are widgets, as well as documents and other tools, that might make it into GWT in the future.
  • gwt-widget: I’ve used this project in the past. Some wrappers (of scriptaculous) and some native classes (SimpleDateFormat, LightBox).
  • sphene: I like the slider and am planning to use it in a project very soon.
  • GWT-Rocket: This provides a whole framework, including many widgets and some replacements for core GWT functionality. I installed and tested their slider functionality, but haven’t looked closer than that.
  • gwt-ext: This project wraps the fine extjs js library, plus more if you pay. I have used this for grid tables and found it great.
  • ext-gwt: This project apparently re-implements extjs, by the folks who wrote extjs. Here’s more about the differences between ext-gwt and gwt-ext.
  • GWTcomponents, which appears abandoned, but might have useful components.
  • gwt-fx: not strictly a widget toolkit, but rather a way to do effects natively.

Here is a page with other libraries that I don’t have a lot of experience with, but might be worth investigating. And looking on google code turns up a large number of projects devoted to GWT extensions.

Technorati Tags: ,



© Moore Consulting, 2003-2017 +