Saturday, October 5, 2013

Re: Using @UiChild with Elements not widgets, is this even possible?

Ah sorry, hadn't looked carefully at your code: with @UiChild(tagname="div"), UiBinder expects a <my:div> ("my" being the same as the containing widget):

<my:customWidget>
  <my:div>
    <ui:HTMLPanel>
      foo
    </ui:HTMLPanel>
  </my:div>
</my:customWidget>

That doesn't change the problem though: apparently (looking at the code), only widgets are allowed. With the above XML, the "my:div" only exists to call the @UiChild method, passing the HTMLPanel as argument.

On Saturday, October 5, 2013 10:49:11 PM UTC+2, Thomas Broyer wrote:
Looks like I was wrong and you can only use widgets (there's an explicit "isImportedElement" test that checks the element is within a namespace whose URI starts with "urn:import:")

BTW, isn't the error message rather "Expected child from a urn:import namespace, found <div>" ?

On Saturday, October 5, 2013 9:56:14 PM UTC+2, GWTter wrote:
Hi all,

Although the doc does say "...add a child widget to..." in my searching it seems as if you can also use UiChild with DOM elements that extend com.google.gwt.dom.client.Element class. Thomas Broyer gives a brief description here. Since it's Thomas I'm thinking this should indeed work, however for the life of me I can't get it to. It always ends up in "found unexpected child element: <div>" when the child is a div element. 

From the comments and the doc it seems that this is the setup you're supposed to have:

@UiChild(tagname = DivElement.TAG)
public void addDiv(DivElement div) {  //note: I've even tried "adddiv" just to be sure
  //do something
}

and in uibinder:

<my:customWidget>
  <div>foo</div>
</my:customWidget>


Do I just have code tunnel vision or is this not possible? Thanks in advance.

-Seth

--
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment