0

I have a dynamically-created HtmlPanelGrid which is working fine. I want to use the same data but group them this time, and it won't work. Current hierarchy is:

Parent(HtmlPanelGrid)
    |-->Child-1(HtmlPanelGrid)
        |-->Child-1-1(Label/CommandButton)
        |-->Child-1-2(Label/CommandButton)
    |-->Child-2(HtmlPanelGrid)
        |-->Child-2-1(Label/CommandButton)
        |-->Child-2-2(Label/CommandButton)

Normally, I was showing it like this:

<h:panelGrid binding="#{configurationManagedBean.dynamicAddonGrid}"/>

where dynamicAddonGrid represents the parent element. But, I want to display a new panelGrid for every first-level child element. So I changed it like this:

<ui:repeat var="group" value="#{configurationManagedBean.dynamicAddonGrid.children}">
    <h:panelGrid binding="#{group}" />
</ui:repeat>

But it shows nothing. This is how I create this hierarchy in the backing bean:

HtmlPanelGrid dynamicAddonGrid = new HtmlPanelGrid();
for(int gridIndex = 0; gridIndex < addonGrids.size(); gridIndex++){
    AddonGrid currentGrid = addonGrids.get(gridIndex);

    HtmlPanelGrid addonComponentPanelGrid = new HtmlPanelGrid();
    addonComponentPanelGrid.setTitle(currentGrid.getDefinition());
    addonComponentPanelGrid.setColumns(8);
    for(int addonIndex = 0; addonIndex < currentGrid.getAddonList().size() ;addonIndex++){
        Addon currentAddon = currentGrid.getAddonList().get(addonIndex);

        HtmlOutputLabel labelComponent = new  HtmlOutputLabel();
        addonComponentPanelGrid.getChildren().add(labelComponent);

        HtmlCommandButton commandButton = new HtmlCommandButton();
        addonComponentPanelGrid.getChildren().add(commandButton);
    }   
    dynamicAddonGrid.getChildren().add(addonComponentPanelGrid);
}

I omitted unrelated business logic for clarification.

Both parent and first-level child elements are HtmlPanelGrids, but somehow, I can't group them. I mean I can, but it just shows nothing. It seems like I'm overlooking something. Any help would be appreciated.

Emre Türkiş
  • 992
  • 9
  • 23
  • 2
    "binding" has exactly same lifecycle as JSTL. So that duplicate applies. However, your underlying [XY-problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) is bigger. For that, head to http://stackoverflow.com/questions/3510614/how-to-create-dynamic-jsf-form-fields Remember: there's **nothing** which is impossible in XHTML and only possible in Java. Only, creating/declaring components in XHTML is so *much* more maintenance friendly. – BalusC Jun 29 '15 at 08:50
  • you don't ever disappoint man. Thanks. This is a legacy project and I didn't want to change the process entirely. I also find it disturbing to create the whole grid in the backing bean too. – Emre Türkiş Jun 29 '15 at 09:02

0 Answers0