On Dec 22, 11:46 pm, ericv <eric.vaut...@gmail.com> wrote: > Starting > point:http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Us... > > My goal here is simply to bind an image, and update it later on if > necessary. I implemented the following code as a first step, but I > keep getting "Found widget <g:Image resource='{resources.logo}'> in an > HTML context". I'm unsure as to what that means; does the container > need to be initialized somehow?
You can only use widgets (<g:Whatever>) as direct children of other widgets, or descendants of <g:HTMLPanel> widgets. > Code: > > public class Sandbox implements EntryPoint { > public void onModuleLoad() { > BinderUiTest test = new BinderUiTest(); > Document.get().getBody().appendChild(test.getElement()); Where the hell have all of you been seeing this code to add widgets to the page? Widgets should be children of other widgets, except for two cases: RootPanel/RootLayoutPanel, and those widgets created by their wrap() static method. In your case: RootPanel.get().add(test); > public class BinderUiTest extends UIObject { > interface MyUiBinder extends UiBinder<DivElement, BinderUiTest> {} > private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); > > @UiField(provided = true) > final Resources resources = Resources.INSTANCE; > > public BinderUiTest() { > setElement(uiBinder.createAndBindUi(this)); > } > > } If you want to have an Image widget as a component of your BinderUiTest object, you have to turn it into a Composite (probably using an HTMLPanel widget as the root object). -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.