pkdevboxy / google-web-toolkit-incubator

Automatically exported from code.google.com/p/google-web-toolkit-incubator
0 stars 0 forks source link

All GWT widgets should implement a single interface each to ease the decorator design pattern #352

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If you want to see this feature/enhancement implemented, please star this
issue by clicking on the star in the upper left hand corner of this page.

== Enhancement Description ==

I would love to have all GWT widget implement each its own dedicated
interface instead of a collection of interfaces.
This would allow implementing the "decorator" design pattern which
encapsulates an object and enriches its behavior.

For instance:

Say I want to decorate (in the 'design patterns' meaning) a TextBox to add
a hint on what the user should fill in when the text box is empty.
Typically, this is what the Firefox search text field does by showing the
name of the search engine.

I could extend TextBox as MyHintTextBox, but then, if I want to re-use this
on a password field I have to create another class
MyHintPasswordTextBox.... which is why I rather use the 'decorator design
pattern'.

So MyHintTextBox needs to extend Composite and wrap any subclass of
TextBoxBase. The issue is that I want it to behave as a TextBoxBase and
others should see it as such.

So I let my MyHintTextBox implement HasClickHandlers, HasAllFocusHandlers,
HasAllKeyHandlers, HasAllMouseHandlers, HasChangeHandlers, HasText,
HasName, HasValue< String >

Wouldn't it be easier to have GWT define a TextBoxInterface defined itself
as extending all of the above interfaces and my MyHintTextBox just
implement that single interface?

All my could would always refer to that TextBoxInterface so that if I pass
a MyHintTextBox, nobody sees a difference.

Thanks in advance!

Original issue reported on code.google.com by jan.vorw...@gmail.com on 29 Apr 2010 at 9:41

GoogleCodeExporter commented 8 years ago
Sorry!!!
I mean't raising this against GWT itself, which was open in another tab of my 
browser!!!
Please close & ignore and apologies again for the noise!!

Original comment by jan.vorw...@gmail.com on 29 Apr 2010 at 9:43