Reputation: 133
I'm currently working on a JSF application with Primefaces 5.0 where the content of a panel should be updated dynamically depending on the current SelectOneMenu selection.
When the selected item changes, a Java method is called that searches the panel by its ID, removes all current child components and replaces them with new ones.
This is all working correctly: The method is called, the panel is found by its ID and the child components are replaced. But for some reason the child widgets never show up on the UI. I've inspected the HTTP response and they're missing there as well.
Any ideas?
The JSF code looks like this:
<p:panel>
<p:selectOneMenu id="artikelFilter" value="#{artikelListController.artikelFilter}" converter="omnifaces.SelectItemsConverter">
<p:ajax event="change" update="createFilterPanel" />
<f:selectItem itemLabel="" itemValue="#{null}" />
<f:selectItems value="#{artikelListController.artikelFilterValues}" />
</p:selectOneMenu>
<p:panelGrid id="createFilterPanel" />
<p:commandButton action="#{artikelListController.addArtikelFilter()}" value="Hinzufügen" disabled="#{artikelListController.artikelFilter == null}" style="margin-left: 15px" />
</p:panel>
and the Java code like this:
public void setArtikelFilter(final Class<? extends ArtikelFilter> clazz) {
PanelGrid createFilterWidget = (PanelGrid) FacesContext.getCurrentInstance().getViewRoot().findComponent("artikelListForm:createFilterPanel");
if (clazz == null) {
artikelFilter = null;
createFilterWidget.getChildren().clear();
}
else if (artikelFilter == null || clazz != artikelFilter.getClass()) {
artikelFilter = constructor().in(clazz).newInstance();
createFilterWidget.getChildren().clear();
createFilterWidget.getChildren().addAll(artikelFilter.getCreateFilterWidgets());
}
}
Upvotes: 1
Views: 654
Reputation: 133
Replacing PrimeFace's PanelGrid
with JSF's built-in HTMLPanelGrid
solves the problem.
Upvotes: 1