Chapter 4. Creating your own widgets
This chapter covers
After you’ve spent some time using and styling the standard widgets GWT provides you, perhaps as you were exploring and extending the example in chapter 3, you may start having a number of questions, such as
- Why isn’t this “thingy” provided as a widget?
- Why can’t widget X do this little extra thing?
- How can I treat a group of widgets that I use regularly as only one widget?
Fear not; the answers to these questions and more are the topic of this chapter. Once you move past any nontrivial application, treating a group of widgets as one new reusable widget is where you’ll spend most of your time—these are known in GWT as Composite widgets.
In this chapter we’ll look at how you can create new widgets. We’ll start with the approach that you’ll use the least often—creating a widget directly from a DOM element. It’s the least-used approach because GWT provides a lot of widgets already, but it does give us the best way of talking through the things you need to think of when looking at the two other approaches we consider: extending an existing widget to give the functionality you need (saves you time and effort) or creating a Composite, as we mentioned.