Primefaces components don't have a parent inside p:dataTable

UI Components for JSF
Post Reply
cipriandobra
Posts: 15
Joined: 20 Apr 2010, 14:30

28 Oct 2011, 09:02

I'm using this code:

Code: Select all

<h:panelGroup id="docTreeContainer">
	<p:dataTable id="docTree" value="#{DocsBean.docList}" var="v">
		<p:column style="width:150px">  
			<f:facet name="header">Name</f:facet>  
			<h:outputText value="#{v.docName}" />  
		</p:column>  
		<p:column style="width:50px">  
			<f:facet name="header">Add</f:facet>  
			<p:selectBooleanCheckbox id="docChecked" value="#{v.docChecked}">  
				<p:ajax execute="docChecked" render=":#{component.parent.parent.parent.clientId}"/>
			</p:selectBooleanCheckbox>
		</p:column>
		<p:column style="width:150px">  
			<f:facet name="header">Detail</f:facet>  
			<p:inputText value="#{v.detail}" />  
		</p:column>
	</p:dataTable>
</h:panelGroup>
When the check-box is clicked I make some processing on the server side and the entire data table should be re-rendered. The problem in this case is that the server side component of p:selectBooleanCheckbox does not have its parent set so the EL expression component.parent cannot be solved (it returns null). If the Primefaces components are replaced with standard components (h:selectBooleanCheckbox and f:ajax) the code works (Column is the parent of the server side h:selectBooleanCheckbox).

I believe this to be useful because I think it's easier/safer to get to the container through parent chain than using ids.

cipriandobra
Posts: 15
Joined: 20 Apr 2010, 14:30

31 Oct 2011, 17:43

The difference between f:ajax and p:ajax, as far as I have seen is that p:ajax attributes are set (setAttributes) during buildView and not during rendering (as it is the case for f:ajax). Probably that is why parent is not set yet in the parent component of p:ajax.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests