Thanks, for the clear explanation. I wasn't aware of this.
If that's how it was designed, I understand it, but I don't think this
is well explained in the documentation and I hope most GWT developers
know this.
And why not extend this functionality to the way I use it so it might
become more useful?

- Ed


On Feb 28, 4:22 am, Stephen Haberman <[email protected]> wrote:
> >    public Widget asWidget() {
> >            return getEnsureUiWidget();
> >    }
>
> You shouldn't be doing this. asWidget wasn't added to allow lazy
> initialization of widgets.
>
> It was added so that dummy widgets can pretend to be widgets--but
> only in tests. When not testing, the assertion:
>
>     assert widget.asWidget() == widget
>
> Should always pass.
>
> In other words, the only implementations of asWidget should ever be:
>
> A) In a real widget:
>
>     public Widget asWidget() {
>       return this;
>     }
>
> B) In a stub/mock/fake widget:
>
>     public Widget asWidget() {
>       throw new RuntimeException("no, i'm not a real widget!");
>     }
>
> While your use of asWidget is creative, it's not at all the intent, and
> so it's not surprising you're seeing odd results.
>
> - Stephen

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to