I have tried to create my own LabelTextBox by subclassing TextBox, but
I'm not sure how to trick the widget so that when it's added, say to a
VerticalPanel, it actually adds my own span element that contains the
label element and the TextBox.getElement() (an InputElement) so that
they all go together.

I can create the span and put the elements inside, but when I add my
widget, only the TextBox's InputElement is actually in the DOM, so
clearly I'm not doing it right using:

        SpanElement spanElem;
        LabelElement labelElem;
        InputElement inputElem;

        public LabelTextBox(String labelText, boolean labelIsHtml, String
className)
        {
                super(); // creates the TextBox

                inputElem = getElement().cast();

                spanElem = Document.get().createSpanElement();
                spanElem.setClassName(className);

                labelElem = Document.get().createLabelElement();
                if ( labelIsHtml )
                        labelElem.setInnerHTML(labelText);
                else
                        labelElem.setInnerText(labelText);

                String uid = DOM.createUniqueId();
                setId(uid);

                spanElem.appendChild(labelElem);
                spanElem.appendChild(inputElem);
        }

        public void setId(String id)
        {
                labelElem.setHtmlFor(id);
                inputElem.setId(id);
        }

--

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.


Reply via email to