【问题标题】:Custom tags in UiBinder filesUiBinder 文件中的自定义标签
【发布时间】:2011-05-04 06:01:21
【问题描述】:

在 UiBinder.ui.xml 文件中使用<g:LayoutPanel> 时,可以指定<g:layer> 标签。其他一些 Google 构建的小部件也有类似的特殊标签 - <g:tab> 甚至还有一个子标签 <g:header>

如何为我自己的小部件指定这些?

【问题讨论】:

标签: gwt uibinder


【解决方案1】:

经过一些 GWT 改进后,此问题的新答案位于 https://stackoverflow.com/a/11785903/439317 。复制如下以避免版主被删除(也许?)。

您可以使用 @UiChild 在您的小部件中声明特殊功能,该小部件可在 UiBinders 中访问。

例如,

class MyPanel extends AbsolutePanel {

    @UiChild
    public void addAt(Widget w, String parameter1, String parameter2) {
         ....

然后,在你的 uiBinder 中,你可以说

<custom:MyPanel>
    <custom:at parameter1="HI" parameter2="Anything you like!">
        <g:AnySingleWidget />
    </custom:at>
</custom:MyPanel>

见@UiChildhttp://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/uibinder/client/UiChild.html

【讨论】:

    【解决方案2】:

    您正在寻找的是 UiBinder 的自定义元素解析器。见this issue。不幸的是,它还不支持。

    您可能对this post 感兴趣,以获取有关如何自行扩展当前解析器的指导。

    【讨论】:

      猜你喜欢
      • 2011-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-13
      • 2012-01-31
      • 1970-01-01
      • 1970-01-01
      • 2015-01-03
      相关资源
      最近更新 更多