I am using GWT version 2.8.2 along with gwt-polymer-elements version 1.7.0.0 to create my application. I need tabs with switchable content which can co-occur multiple times on the same page. I try to achieve that by using a combination of PaperTabs and IronPages.

I added the custom UiBinder.

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

I dynamically add divs to ironPages:

Replaced ironPages.add(new HTML("<div>" + outerBox + "</div>")); with:

SafeHtmlBuilder outerBoxBuilder = new SafeHtmlBuilder();

outerBoxBuilder.appendHtmlConstant("<div>")
.append(SafeHtmlUtils.fromTrustedString(outerBox.toString()))
.appendHtmlConstant("</div>");

ironPages.add(new HTML(outerBoxBuilder.toSafeHtml()));

Where each outerBox is defined below:

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);
}

New paper tabs are generated similarly:

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

@UiHandler("paperTabs")
void tabSelected(IronSelectEvent event) {
    PaperTabElement tab = Js.cast(event.getItem());
    ironPages.setSelected(tab.getAttribute("q"));
}

It works when the page is loaded for the first time. When I navigate between different pages composite widget loses its functionality. On click on either paperTab or checkbox in ironPages they simply disappear. Seems like widgets are being cleared and lose all children elements.

Does anyone have any suggestions? Is there something I miss?

0

There are 0 answers