Short story: javax.faces.component.UIComponent.getChildren() for <p:toolbar> or <p:column> will return an empty list if they have a <f:facet>
Long story:
I have the following code:
Code: Select all
<h:form id="parentForm">
<p:toolbar>
<f:facet name="left">
<p:inputText id="childText">
</f:facet>
</p:toolbar>
<p:dataTable>
<p:column>
<f:facet name="header">
<p:triStateCheckbox id="childCheckbox">
</facet>
</p:column>
</<p:dataTable>
</h:form>
In this case, I have the id of the parentForm and I want to disable childText and childCheckbox.
I am doing a recursive search and I am disabling all the components with some exceptions.
Code: Select all
public void disableUIComponent(String uiComponentName) {
UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(uiComponentName);
if (component != null) {
disableAll(component.getChildren());
}
}
private void disableAll(List<UIComponent> components) {
for (UIComponent component : components) {
// 15 lines of codes where I am disabling all types of UI components
//component.setDisabled(true);
disableAll(component.getChildren());
}
}
If the toolbar or the column doesn't have the <f:facet> component, component.getChildren() will return the children components.