Wednesday, September 3, 2014

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

Hi,
 
I would love seeing some improvements to UiBinder that it would allow String of SafeHtml for children. I don't want my templates to be full of HTMLPanel when just a String or SafeHtml would do. Specifying these "children" using attributes is not really a great idea since I don't want to escape html in an attribute in a UiBinder file.
 
David
 

On Saturday, October 5, 2013 11:48:17 PM UTC+2, Seth wrote:
Hi Thomas,

Just one last thing, are there still no plans for uibinder element parsing functionality extension like the patch in this issue? Would be preeetty awesome.

On Saturday, October 5, 2013 10:54:36 PM UTC+2, Thomas Broyer wrote:
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/d/optout.

No comments:

Post a Comment