Monday, January 2, 2012

Re: Using inside of a @UiChild

Label implements HasText, so it can contain text that is then passed to setText (as if you used a text="" attribute on the element).
Button implements HasHTML, so it can contain HTML that is then passed to setHTML.
Both cases are handled by specialized ElementParsers (HasTextParser and HasHTMLParser) that make use of "interpreters" (TextInterpreter and HtmlInterpreter respectively) that in turn defer to some other interpreters (TextPlaceholderInterpreter and UiTextInterpreter for TextInterpreter, HtmlInterpreter adds UiSafeHtmlInterpreter and various interpreters working on attribute values –to resolve {} references–)
@UiChild are handled by the UiChildParser.

Now, back to your question: you cannot use @UiChild with a String, it must be either a DOM element (a subclass of com.google.gwt.dom.client.Element; the type of the declared attribute is matched to the type corresponding to the element used in the ui.xml by looking at the @TagName annotations on the Element subclasses) or an "imported class" (i.e. you used an xmlns:XXX="urn:import:the.package" and then <XXX:TheClass>).
If you want to set a text property from a ui.xml, you have to use an attribute (in your case: errorMessage="the message"); and that means you cannot use <ui:msg>. You can however use the <ui:attribute> to localize the value (it's only documented for "HTML attributes" <http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinderI18n.html#HTML_attributes_that_need_translation> but looking at the code it should also work for widgets), or of course a {} reference to an external Constants or Messages method.

--
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/-/J0hfkoOCXN0J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment