Thanks, actually I didn't read the example before adding the comment :-) Changed it to extend UIObject and removed getElement method. The changes will be pushed with the next release.
On Thu, Feb 7, 2013 at 4:27 PM, Jens <[email protected]> wrote: > > > Am Freitag, 8. Februar 2013 00:38:37 UTC+1 schrieb Goktug Gokdogan: > >> FYI, documentation is updated to emphasize that related code sample will >> not work with widgets. >> > > A bit more should be corrected. The simple Hello World class example is > IMHO terrible for starters. > > public class HelloWorld { > > interface MyUiBinder extends UiBinder<DivElement, HelloWorld> {} > > private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); > > @UiField SpanElement nameSpan; > > public HelloWorld() { > > setElement(uiBinder.createAndBindUi(this)); > > } > > public void setName(String name) { nameSpan.setInnerText(name); } > > public void Element getElement() { return nameSpan; } > } > > HelloWorld helloWorld = new HelloWorld(); > // Don't forget, this is DOM only; will not work with GWT widgets > Document.get().getBody().appendChild(helloWorld.getElement()); > > helloWorld.setName("World"); > > > First, HelloWorld has no super class but uses the (undefined) method > setElement() in its constructor. Second, getElement() returns the nameSpan > variable and is used in the second code example to append the Hello World > UiBinder to the body element. A starter sees code that does not compile and > if he assumes that setElement() is maybe the corresponding setter for > getElement() { return nameSpan; } then its totally wrong because nameSpan > is already assigned via @UiField. > > To make things clear getElement() should return the DivElement returned by > createAndBindUi() *or* HelloWorld should extend UiObject and have its > getElement() { return nameSpan; } method removed. > > > -- J. > > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > To post to this group, send email to [email protected]. > Visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
