manolo / gwt-polymer-elements

Polymer Web Components for GWT. A collection of Material Design widgets for desktop and mobile.
Apache License 2.0
156 stars 49 forks source link

UiBinder is not properly working with Iron-list #156

Open Jay-17 opened 6 years ago

Jay-17 commented 6 years ago

Hi, I have added a paper-button to iron-list template.

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:i='urn:import:com.vaadin.polymer.iron.widget' xmlns:p='urn:import:com.vaadin.polymer.paper.widget'>

<g:HTMLPanel addStyleNames="iron-list-sample">
    <style is="custom-style">
        .iron-list-sample paper-scroll-header-panel {
            @apply(--layout-fit);
            @apply(--layout-vertical);
            @apply(--paper-font-common-base);
            margin-top: 50px;
        }
        .iron-list-sample iron-list {
            background-color: var(--paper-grey-200, #eee);
            padding-bottom: 16px;
        }
        .iron-list-sample .item {
            @apply(--layout-horizontal);
            margin: 16px 16px 0 16px;
            padding: 20px;
            border-radius: 8px;
            background-color: white;
            border: 1px solid #ddd;
        }
        .iron-list-sample .avatar {
            height: 40px;
            width: 40px;
            border-radius: 20px;
            box-sizing: border-box;
            background-color: #DDD;
        }
        .iron-list-sample .pad {
            padding: 0 16px;
            @apply(--layout-flex);
            @apply(--layout-vertical);
        }
        .iron-list-sample .primary {
            font-size: 16px;
            font-weight: bold;
        }
        .iron-list-sample .secondary {
            font-size: 14px;
        }
        .iron-list-sample .dim {
            color: gray;
        }
    </style>

    <i:IronList ui:field="list" indexAs="_id" as="item" addStyleNames="fit">
        <template>
            <div>
                <div class="item">
                    <img id="avatar" class="avatar" src="[[item.image]]"/>
                    <div class="pad">
                        <div class="primary">[[item.name]]</div>
                        <div class="secondary">[[item.shortText]]</div>
                        <div class="secondary dim">[[item.longText]]</div>
                       <p:PaperButton ui:field="button">Create new item</p:PaperButton>
                    </div>
                    <iron-icon id ="icon" icon="star"/>
                </div>
            </div>
        </template>
    </i:IronList>
   <div>
   <!-- <iron-icon id ="icon1" icon="star"/> -->
   </div>
</g:HTMLPanel>

</ui:UiBinder>

But I am getting following error in chrome developer console

Throwable.java:121 Uncaught Error: java.lang.RuntimeException: Cannot find element with id "gwt-uid-1". Perhaps it is not attached to the document body. at iA_g$.Dz_g$ [as createError_0_g$] (Throwable.java:121) at iA_g$.Nz_g$ [as initializeBackingError_0_g$] (Throwable.java:113) at iA_g$.wz_g$ (Throwable.java:67) at iA_g$.aA_g$ (Exception.java:29) at new iA_g$ (RuntimeException.java:29) at WAd_g$.XAd_g$ [as get_16_g$] (LazyDomElement.java:70) at P3f_g$.C9f_g$ [as build_button_0_g$] (IronListSample_SampleUiBinderImpl.java:150) at P3f_g$.D9f_g$ [as get_button_0_g$] (IronListSample_SampleUiBinderImpl.java:146) at P3f_g$.U3f_g$ [as build_list_0_g$] (IronListSample_SampleUiBinderImpl.java:131) at P3f_g$.Z3f_g$ [as get_list_0_g$] (IronListSample_SampleUiBinderImpl.java:117) at P3f_g$.T3f_g$ [as build_f_HTMLPanel1_1_g$] (IronListSample_SampleUiBinderImpl.java:93) at P3f_g$.Y3f_g$ [as get_f_HTMLPanel1_1_g$] (IronListSample_SampleUiBinderImpl.java:76) at J3f_g$.L3f_g$ [as createAndBindUi_2_g$] (IronListSample_SampleUiBinderImpl.java:34) at J3f_g$.K3f_g$ [as createAndBindUi_0_g$] (IronListSample_SampleUiBinderImpl.java:31) at new F3f_g$ (IronListSample.java:31) at w5f_g$ (Test.java:75) at Function.C5f_g$ (Test.java:73) at lambda_0_g$ (Runtime.java:162) at registered_0_g$ (Polymer.java:422) at ioe_g$ (Polymer.java:437) at hoe_g$ (Polymer.java:398) at CZf_g$.DZf_g$ [as onModuleLoad_0_g$] (Test.java:73) at Array.iAc_g$ (org_00046com_00046Test__EntryMethodHolder.java:3) at initializeModules_0_g$ (ModuleUtils.java:44) at qJ_g$ (Impl.java:239) at tJ_g$ (Impl.java:298) at Impl.java:77 at Czc_g$ (ModuleUtils.java:55) at Test.java:73

when I remove ui:field="button" from the paper-button then there is no error but I can not bind paper-button in ui class