GWT 如何在 UiBinder 中创建 ul li widget



我想在 gwt 中生成<ul><li>元素。我想知道如何实现这一目标。有人可以帮忙吗?

我使用 gwt 2.7

UiBinder代码

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder 
    xmlns:ui='urn:ui:com.google.gwt.uibinder'
    xmlns:g='urn:import:com.google.gwt.user.client.ui'
    >

        <li ui:field="listItem" class="menu open">
            <m:MaterialLink ui:field="hyperlink" textColor="blue"></m:MaterialLink>
        </li>

</ui:UiBinder>

爪哇代码

@UiField LIElement listItem;

控制台输出

[INFO] GET /recompile/cms
[INFO]    Job pl.daniel.cms.cms_1_69
[INFO]       starting job: pl.daniel.cms.cms_1_69
[INFO]       Compiling module pl.daniel.cms.cms
[INFO]          Computing all possible rebind results for 'pl.daniel.cms.client.ui.template.menu.GatekeeperProtectedMenuEntry.Binder'
[INFO]             Rebinding pl.daniel.cms.client.ui.template.menu.GatekeeperProtectedMenuEntry.Binder
[INFO]                Invoking generator com.google.gwt.uibinder.rebind.UiBinderGenerator
[INFO]                   [ERROR] Not allowed in an HTML context: <m:MaterialLink textColor='blue' ui:field='hyperlink'> (:12)
[INFO]          [ERROR] Errors in 'gen/pl/daniel/cms/client/ui/template/menu/com_gwtplatform_mvp_client_DesktopGinjector_DesktopGinjectorGinjector_fragment.java'
[INFO]             [ERROR] Line 93: Failed to resolve 'pl.daniel.cms.client.ui.template.menu.GatekeeperProtectedMenuEntry.Binder' via deferred binding
[INFO]          Unification traversed 1505 fields and methods and 454 types. 7 are considered part of the current module and 7 had all of their fields and methods traversed.
[INFO]          [WARN] Some stale types ([pl.daniel.cms.client.ui.template.menu.GatekeeperProtectedMenuEntry_BinderImpl, pl.daniel.cms.client.ui.template.menu.GatekeeperProtectedMenuEntry_BinderImpl$Widgets]) were not reprocessed as was expected. This is either a compiler bug or a Generator has legitimately stopped creating these types.
[INFO]       [ERROR] Compiler returned false
[INFO]       [WARN] recompile failed
[INFO]       [WARN] continuing to serve previous version

添加一个HTMLPanel作为小部件的根目录。 HTMLPanel是默认值,但不必是 HTMLPanel ,它也可以是FlowPanel或其他东西。

所以这样的事情就可以了:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder 
    xmlns:ui='urn:ui:com.google.gwt.uibinder'
    xmlns:g='urn:import:com.google.gwt.user.client.ui'
    xmlns:m='urn:import:gwt.material.design.client.ui'
>
<g:HTMLPanel>
    <li ui:field="listItem" class="menu open">
        <m:MaterialLink ui:field="hyperlink" textColor="blue"></m:MaterialLink>
    </li>
</g:HTMLPanel>

相关内容

  • 没有找到相关文章