The purpose of this method is to bind the structured widget you build within your Composite widget with the underlying widget hold by the composite. This pattern allows you to customize your Composite with any subclass A of Widget without exposing the methods of A.
For instance, suppose you want to make a widget which inherits the behavior of a Button object. Though you want to create a widget which benefit from the features implemented in the Button class, you do not want to expose the Button method to the client of your Composite class (because you want to hide the implementation for instance). Using the composite object, your Button object is encapsulated and hidden to the client while you composite object benefits from its features. This principle admitted, initWidget() method has to be called once since it defines the underlying nature of your Composite component, which must not change over the life time of your object (because the nature of your Composite object is intrasically bound to its underlying widget). I guess GWT forbids to call initWidget() more than once so as to avoid to break this contract. Alexandre. On 15 sep, 15:15, wahaha <[email protected]> wrote: > the class Composite has a protected method initWidget(). > > the javadoc says: > This method may only be called once for a given composite. > why? -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
