Saturday, April 18, 2015

UiBinder with an immediate webcomponent tag?

If I use a ui.xml file that looks like:

<ui:UiBinder ...>
    <div>
        <my-webcomp>
            ...
        </my-webcomp>
    </div>
</ui:UiBinder>

and the code: 
  interface MyUiBinder extends UiBinder<Element, MyWidget> { }

everything works as expected, _but_ I would like to strip away the excess div-tag so that <my-webcomp> becomes the immediate child tag of UiBinder.  However, that results in an error from the generator: 

[INFO]       Rebinding ....MyUiBinder
[INFO]          Invoking generator com.google.gwt.uibinder.rebind.UiBinderGenerator
[INFO]             [ERROR] Illegal field name "f_my-webcomp1"

So far, I've worked around the problem by doing:

  Element elem = uiBinder.createAndBindUi(this);
  elem = (Element) elem.getChild(0);
  setElement(elem);
  mywebcomp = getElement().cast();


I did try supplying the @JsType-marked interface corresponding to the webcomponent as the first generic arg to UiBinder, but that didn't help either, but technically, is there any reason it cannot be made to work?

Regards,
Henrik

--
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