Children components inside <f:facet> are not seen in backend

UI Components for JSF
Post Reply
mirceaalbu
Posts: 1
Joined: 21 Jun 2018, 18:03

21 Jun 2018, 18:44

Hi,

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 the backend, I need to disable an entire component and their childrens.
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());
	}
}
The problem is that component.getChildren() will be empty if the <f:facet> is present.
If the toolbar or the column doesn't have the <f:facet> component, component.getChildren() will return the children components.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

22 Jun 2018, 09:41

try component.getFacet(...).getChildren()
otherwise try StackOverFlow, it's not related to PrimeFaces, it's more related to the JSF API/Impl.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 46 guests