Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gwt IronPages&;PaperTabs与动态创建的子项的组合在多次使用时消失_Gwt_Gwt Polymer_Iron Pages - Fatal编程技术网

Gwt IronPages&;PaperTabs与动态创建的子项的组合在多次使用时消失

Gwt IronPages&;PaperTabs与动态创建的子项的组合在多次使用时消失,gwt,gwt-polymer,iron-pages,Gwt,Gwt Polymer,Iron Pages,我正在使用GWT 2.8.2版和GWT polymer elements 1.7.0.0版来创建我的应用程序。我需要与切换内容,可以在同一页上多次出现的标签。我试图通过结合使用纸质标签和铁皮来实现这一点 我添加了定制的UiBinder <i:IronPages ui:field="ironPages"></i:IronPages> <p:PaperTabs ui:field="paperTabs" scrollable="true"></p:Pa

我正在使用GWT 2.8.2版和GWT polymer elements 1.7.0.0版来创建我的应用程序。我需要与切换内容,可以在同一页上多次出现的标签。我试图通过结合使用纸质标签和铁皮来实现这一点

我添加了定制的UiBinder

<i:IronPages ui:field="ironPages"></i:IronPages>    
<p:PaperTabs ui:field="paperTabs" scrollable="true"></p:PaperTabs>
UiHandler

@UiHandler("paperTabs")
void tabSelected(IronSelectEvent event) {
    PaperTabElement tab = Js.cast(event.getItem());
    ironPages.setSelected(tab.getAttribute("q"));
}
它在第一次加载页面时工作。当我在不同页面之间导航时,复合小部件将失去其功能。在ironPages中单击paperTab或复选框,它们就会消失。小部件似乎正在被清除并丢失所有子元素


有人有什么建议吗?有什么我遗漏的吗?

第一件事:不要在小部件上使用toString(或getInnerHTML)(当您将outerBox与
s连接时)。如果你想创建一个HTML字符串,请使用SafeHtmlBuilder。我编辑了代码,请看一看。这并没有更好:你仍然在一个小部件上调用toString。
for(int i: total){
    PaperMaterial outerBox = new PaperMaterial();
    HTML boxTitle = new HTML("<h2>Some title</h2>");
    outerBox.add(boxTitle);

    PaperMaterial innerBox = new PaperMaterial();
    PaperCheckbox checkBox = new PaperCheckbox();
    // checkBox.getElement().setInnerText("label");
    checkBox.getElement().setInnerSafeHtml(
        new SafeHtmlBuilder().appendEscaped("label").toSafeHtml()
    );

    innerBox.add(checkBox);
    outerBox.add(innerBox);
}
PaperTab singleTab = new PaperTab();
// singleTab.getElement().setInnerHTML("some text");
singleTab.getElement().setInnerSafeHtml(
    new SafeHtmlBuilder().appendEscaped("some text").toSafeHtml()
);
singleTab.getElement().setAttribute("q", pageNumber);
paperTabs.add(singleTab);
@UiHandler("paperTabs")
void tabSelected(IronSelectEvent event) {
    PaperTabElement tab = Js.cast(event.getItem());
    ironPages.setSelected(tab.getAttribute("q"));
}