TemplateRenderer不会渲染bean

时间:2019-05-01 20:14:06

标签: vaadin vaadin-grid vaadin-flow vaadin10

我正尝试在要将模型传播到前端的地方使用TemplateRenderer

userGrid.addColumn(TemplateRenderer.<UserProjection>of(
        "<user-card"
                + " userDetail='[[item.userDetail]]'"
                + " licenses='[[item.licenses]]' "
                + " test='[[item.test]]'"
                + " id='[[item.id]]'"
                + ">"
                + "</user-card>")
        .withProperty("userDetail", user -> user)
        .withProperty("licenses",
                user -> userService.findAllUserLicenses(user.getId()).stream().map(License::new).collect(Collectors.toList()))
        .withProperty("test", UserProjection::getEmail)
        .withProperty("id", UserProjection::getId)
);

这是我的模板

<link rel="import" href="../../bower_components/polymer/polymer-element.html">

<link rel="import" href="../../styles/shared-styles.html">


    <dom-module id="user-card">
        <template>

            <div class="content" on-click="_onClick">
                <div>[[test]] [[id]] [[userDetail.id]] </div>
                <div class="user-details">

                    <h1>[[userDetail.firstName]] [[userDetail.lastName]]</h1>
                    <h3>[[userDetail.email]]</h3>
                </div>
                <dom-repeat items="[[licenses]]">
                    <div class="license">
                        {{item.validTo}}
                    </div>
                </dom-repeat>
            </div>

        </template>
        <script>
            class UserCard extends Polymer.Element {
                static get is() {
                    return "user-card";
                }

                _onClick() {
                    this.dispatchEvent(new CustomEvent('card-click'));
                }
            }

            window.customElements.define(UserCard.is, UserCard);
        </script>
    </dom-module>

user-card模板也包含在我使用网格的模板中。我可以成功显示属性testid,但是我无法使用userDetaillicenses。有人可以告诉我我在做什么错吗?我正在使用vaadin 13.0.5

0 个答案:

没有答案