On Wednesday, October 26, 2011 1:54:38 PM UTC+2, Gervais.b wrote:
>
> Hi all,
>
> I'm playing with GWT since some weeks and now I want to create a form
> (not int Html sense); In this form I want to use the Html <label> tag
> to set focus on the field referenced by the "for" attribute value.
>
> 1° <label for="fldFirstName"><g:InlineLabel text="{msg.firstName}" /></
> label>
> But that don't works because GWT "ui:field" don't set the Id to the
> field.
>
Yes, and there's a good reason for this (performance IIRC, and also the GWT
team wanted to try other approaches than getElementById to retrieve the
elements).
> 2° So I have tried to give an id to my field but now GWT complaints
> because we can use "id" with "ui:field".
>
> 3° I have Googled a little and found a topic who use en expression to
> retrieve the field id :
> <label for="{fldFirstName.getElement.getId}"><g:InlineLabel
> text="{msg.firstName}" /></label>
> But the "for" attribute stay empty.
>
Yes, because as you said, ui:field doesn't set an ID on the element
(actually, it does set one, but removes it right after use).
> 4° I have decided to tell you "Why GWT ignore standard html tags ?"
> and force us to write many boilerplate code for simple things ?
>
There are features that, if not done correctly, would cause a lot of bugs
being reported, and would effectively move resources (human resources I
mean) on fixing those rather than improving the toolkit.
There are ways to do what you want without too much
boilerplate:
https://docs.google.com/Doc?docid=0AQcd-Zsy2T-YZG1mZG5jNl84Z3NkMmJuZHo
And there are ways to do it without without writing any code:
<label><ui:text from="{msg.firstName}" /> <g:TextBox
ui:field="fldFirstName" /></label> Just Works™, because the textbox is
within the <label>, so there's no need for a for="" attribute.
> I think that the GWT has made an impressive work but I don't
> understand why in many cases we have to ignore "Html best pratice"
You don't have to.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/tlQQnh3Ap6IJ.
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.