On Dec 3, 4:45 am, Open eSignForms <
yoz...@gmail.com> wrote:
> Does anybody know the history as to why GWT's Label widget uses a
> <div> instead of a <label> tag?
Probably because the Label widget is only for showing some text, not
necessarily label an input widget (such as a TextBox).
I also think GWT has not a really good history regarding accessibility
(feel free to disagree with me)
> The label tag allows the label to be tied to another element, such as
> the input tag, for accessibility, yet that seems lost with the Label
> widget.
GWT is hiding HTML, the DOM, etc. from developers (when using widgets'
"high level" APIs), so that developers don't depend on widgets
internals. For instance, there's no method for setting a widget's
"ID", you have to getElement().setId("myId"); but there's a method for
setting IDs for debugging purposes (ensureDebugId).
This means that if GWT had such a widget, it'd probably have a
setLabeledControl(...) method (to have a friendly API); which means
that:
- the NewLabel widget would have to create the ID of the labeled
control, which means it'd break as soon as ensureDebugId is called on
the labeled control
- the "link" between NewLabel and its labeled control would break as
soon as the labeled control's ID is changed, which breaks the
assumption that the "link" is between the widgets (you passed a Widget
to setLabeledControl, not an ID)
- because per the HTML spec [1,2], the for="" attribute references a
"control" [3,4], setLabeledControl would have to check the widget
argument for being "labelable". It'd better be done at compile time
than runtime, which would mean constraining the use of NewLabel to
labeling known widgets: TextBox (PasswordTextBox extends TextBox),
ListBox, TextArea, Button, FileUpload, SimpleCheckBox
(SimpleRadioButton extends SimpleCheckBox); which rules out user-
defined widgets, even if they use a "labelable" DOM element (well,
eventually, there could be a Labelable interface, but implementing it
wouldn't be enough for the NewLabel to "work")
[1]
http://www.w3.org/TR/html4/interact/forms.html#adef-for
[2]
http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#attr-label-for
[3]
http://www.w3.org/TR/html4/interact/forms.html#h-17.2
[4]
http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#category-label
If you were to have a setLabeledControlID(String) instead of
setLabeledControl(Widget), it'd mean you expect people to use the
lower-level getElement().setId(...) method of the labeled widget,
which also means they are aware that it can play quite badly with
ensureDebugId. Providing a high-level API (NewLabel widget and its
setLabeledControlID method) that requires users to use low-level APIs
in other widgets in order to use it, looks weird.
I think GWT doesn't include such a widget for all these reasons. If
you want such a widget, you have to know the implications, i.e. know
GWT's internals, which means you are capable of writing the widget
yourself.
If GWT provided such a widget, expect a high number of bug reports,
just because people do not understand the implications, which means
incidentally much (too much) time spent on "fixing" the widget to make
it reliably work in almost all situations.
> Seems like Label was a misnomer and should have been called Text to
> parallel HTML.
Many widgets in other toolkits are called "label" without the
associated meaning of being associated with a control; for instance
java.awt.Label:
http://java.sun.com/javase/6/docs/api/java/awt/Label.html
> As for myself, I essentially copied the GWT Label widget source to
> make my own Label that creates a <label> instead.
As for myself, I'm now using UiBinder, so the <label> is in the
*.ui.xml and if the labeled control has to be a widget, then in my
Java code I assign the labeled widget's ID and the label for="" to the
same createUniqueID() value.
You can search the GWT-C archives for a proposal to better handle this
in UiBinder; I also have a proposal (as a private Wave), but I'm
waiting for 2.0 to be released to make it public and actually discuss
it.