Wednesday, April 28, 2010

Extending widgets for use with UIBinder

UIBinder, as released with GWT 2, is convenient because it allows us to specify our UI structure through XML.

However, the maturity of UIBinder is left in question because many useful GWT widgets are quite unusable in UIBinder, placing in question the deployment capability of UIBinder in any practical project. Not that they are unusable, but UIBinder allows them to function only as child widgets, and hence, incapable of having children within the UIBinder framework.

This article tells you how to write wrappers around GWT widgets to make them available for use as parent widgets with UIBinder. In fact, you can even place such wrappers around SmargGWT widgets.

Rule: Must implement HasWidgets Interface.
Any GWT widget to be used with UIBinder must implement the interface
com.google.gwt.user.client.ui.HasWidgets.

HasWidgets interface requires your wrapper to make the following methods available.

void add(Widget w);
void clear();
Iterator<Widget> iterator();
boolean remove(Widget w);

This is especially true with widgets that inherit the restriction of the SimplePanel abstract widget. SimplePanel widgets can only have one child and a child is acquired through the setWidget method, without implementing the HasWidgets interface.

Exception to Rule: Otherwise, patch-extend an insider-traded widget.
There are existent UIBinder widgets which do not implement HasWidgets. This is due to GWT insider-trading with some of the repertoire of UIBinder widgets - the GWT compiler recognises the type of those widgets and has insider-coded their UIBinder child and attribute specification and constraints. The only way to overcome the unfair advantage these widgets have is by patch-extending them. We fool the GWT compiler into believing it is compiling one of its own insider-traded widgets by extending such widgets.

You might be asking, if a widget is already capable as a parent widget with UIBinder, what is the point of wrapping them? The reason is to expand the repertoire of widgets allowed to be its children. Since the GWT compiler has already insider-coded what such widgets are allowed to have as children.

What I mean by patch-extending is, placing the extension class within the same package namespace - by stealing into the namespace com.google.gwt.user.client.ui. Primarily, due to needing access to default and protected objects of the original widget.

And, what I mean by insider-trading of UIBinder widgets is the existence of parsers specialised for a bunch of widgets, where we (end-user-programmers) have scantly any way of inserting our own parser:
http://code.google.com/p/google-web-toolkit/source/browse/#svn/trunk/user/src/com/google/gwt/uibinder/elementparsers. Unless we built our own gwt-user.jar.

17 comments:

  1. Small White Coach Purse, Though Schuplinski responsibilities were running backs and special teams, the two still developed a close relationship.In fact, Arth presence was a significant factor in Schuplinski return to JCU, as he told Blue Streak Nation (a web site covering JCU sports) in March. The opportunity to work with a guy I have a lot of respect for, Tom Arth, and a lot of other guys on the staff who I know, it been awesome, he said. Think John Carroll is a really special place.

    Coach Bags Outlet Thailand, Some good plays, yes. Some good throws, yes. But a lot of the issues that have plagued Hurts as a passer made themselves evident again during A Day: missed receivers, holding onto the ball for too long and plain bad throws.

    Perhaps the best example of Austin architecture is the Governor's Mansion (1010 Colorado St). Designed by Abner Cook, who specialized in the Federal style of homes for mostly private residences, the Governor's Mansion was constructed between 1854 and 1856. It has a decidedly Greek Revival look to it, characterized by two story porticos, Doric columns, and Cook's signature X and sticks motif for upper and lower balustrades. (Michael Kors Grey And Black Bag)

    A lot of the growth we're seeing is because women are more liberalized and wanting to try anything that a guy can do. And that's the instinct I think many of those girls have, said Jay LaValley, the chairman of the Maryland State Wrestling Association. "They don't let anything hold them down or put limits on themselves.". (Michael Kors Black Leather Fulton Shoulder Bag)

    Within a shop, especially if you have an unskilled leader, this can extend to everyone hating everybody, and yelling all the time. At the moment, nobody wants to leave the military because they're afraid they won't get another job in this economy, which means that most places are top heavy. If you have the common situation where there's four guys of the same rank in the shop (for an office analogy, imagine more managers than workers), they will all be fighting constantly over who can do the most nothing, while the lower ranking guys do all the work.. (Michael Kors Fulton Crossbody Bag Leather Black)

    ReplyDelete
  2. Air Jordan Future Premium Black Glow, It was the city largest single day jump in reported deaths since the outbreak of the pandemic.The new deaths were all related to outbreaks in long term care and retirement homes, bringing the total COVID 19 related deaths in those facilities to 12.thoughts are with the family members, friends, and caregivers of the people who have died, Ottawa chief medical officer Dr. Vera Etches said in a statement. Continues to work with health care partners to ensure long term care and retirement homes are a top priority for protection.

    Jordan Retro 13 Black And Island Green, Raise FundsTickets are heavily discounted, and a significant portion of the ticket price goes directly back to your school. Los Angeles Kings is a trademark of Los Angeles Kings, LLC. NHL, the NHL Shield, the word mark and image of the Stanley Cup and NHL Conference logos are registered trademarks of the National Hockey League..

    In addition to Beckett on piano and behind the console, Alabama musicians on the sessions included Shoals via Birmingham guitar hotshot Wayne Perkins, who'd graced Bob Marley and Rolling Stones cuts. {tag: Adidas Yeezy Boost 350 V2 Triple White Release}

    Air Jordan Black Friday 2015, To add a family member's name to the tree, double click the sample text and type over it. To add a photo, click on the picture placeholder in the center of the shape associated with that person. The Insert Picture dialog opens, so you can navigate to the image you want to use..

    Jordan 5 Black Yellow, HomeNewsUK NewsMirror Reader OffersSign up to FREE email alerts from Mirror daily newsSubscribeWhen you subscribe we will use the information you provide to send you these newsletters. Sometimes they'll include recommendations for other related newsletters or services we offer. OurPrivacy Noticeexplains more about how we use your data, and your rights.

    ReplyDelete
  3. This blog was very nicely formatted; it maintained a flow from the first word to the last. Kung Fury Jacket

    ReplyDelete
  4. The great website and information shared are also very appreciable. Attack On Titan Jacket

    ReplyDelete
  5. Our the purpose is to share the reviews about the latest Jackets,Coats and Vests also share the related Movies,Gaming, Casual,Faux Leather and Leather materials available Barley Lightfoot Vest

    ReplyDelete
  6. Hi , Thank you so much for writing such an informational blog. For more information Click on Gotham Knights Red Hood Vest

    ReplyDelete
  7. I must say that you are my favourite author. You always bring surprised things for me everytime I see your articles. Great efforts!! Akatsuki Puffer Coat

    ReplyDelete
  8. I was very impressed by this post, this site has always been pleasant news Thank you very much for such an interesting post, and I meet them more often then I visited this site. Leather Peacoat

    ReplyDelete