Expand dataTable or placing a dataTable in a dataTable fails

UI Components for JSF
Post Reply
HalloSchwester
Posts: 10
Joined: 11 Nov 2009, 11:15

28 Jan 2011, 10:59

Hi!

I'm trying to expand a dataTable by adding another dataTable inside the first. The idea is that I expand a row (service info) to display all customers of this service. These customers should be displayed in a second dataTable.

The sdh.sd.id is always null when given to the getCustomersOfService method (providerStart.getCustomersOfService(sdh.sd.id)).
Therefore, I preselect the row before clicking on the rowToggler. The interesting thing is that this most of the time does not work but sometimes it does. Most of the time I get a NullPointerException because the selection does not work (i.e. the backing bean is not set. I also set a background which was not reached). If I remove the facet expansion, the selection works fine.


Code: Select all

                                           <p:dataTable id="publishedServicesDataTable" var="sdh"
							value="#{providerStart.publishedServices}"
							selection="#{providerStart.selectedService}" 
							selectionMode="single" update="proxy">
							<p:column style="width:16px">
								<p:rowToggler /> 
							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="ID" />
								</f:facet>
								<h:outputText value="#{sdh.sd.id}" />
							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="Service Name" />
								</f:facet>
								<h:outputText value="#{sdh.name}" />
							</p:column>
							<f:facet name="expansion">
								<p:dataTable id="customersOfService" var="cust"
									value="#{providerStart.getCustomersOfService(sdh.sd.id)}">
									<p:column>
										<f:facet name="header">
											<h:outputText value="ID" />
										</f:facet>
										<h:outputText value="#{cust.id}" />
									</p:column>
									<p:column>
										<f:facet name="header">
											<h:outputText value="Organisation" />
										</f:facet>
										<h:outputText value="#{cust.organization.name}" />
									</p:column>
									<p:column>
										<f:facet name="header">
											<h:outputText value="Contact Person" />
										</f:facet>
										<h:outputText value="#{cust.firstname} #{cust.lastname}" />
									</p:column>
									<p:column>
										<f:facet name="header">
											<h:outputText value="E-Mail" />
										</f:facet>
										<h:outputText value="#{cust.email}" />
									</p:column>
								</p:dataTable>
							</f:facet>
						</p:dataTable>
			<p:dialog id="proxy" rendered="false" /> 
So basically, two things do not seem to work properly. The first thing is the usage of a value as input of the value attribute in the second datatable that depends on the "var" in the first datatable. The second thing is the selection does not work properly when adding the facet expansion (with a second datatable).

Do you have any advise how I could circumvent the problem?

I'm using Primefaces 2.2 RC2 and run it on JBoss 6 (JSF 2; Mojarra 2.0.3).

Best,
HalloSchwester

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

28 Jan 2011, 11:06

Try 2.2-SNAPSHOT and replace expansion facet with p:rowExpansion.

HalloSchwester
Posts: 10
Joined: 11 Nov 2009, 11:15

28 Jan 2011, 12:08

Hi!

Thanks! That's definitely a first shot. The problem now is that for every entry in the first table the data from the second table is fetched whenever I select a line or try to expand a table. So expanding a line approximately takes one minute because all the data associated with the first table is loaded (and that perhaps multiple times).

Any further suggestion? Any attributes on rowExpansion that could be used?

Best and thanks again,
HalloSchwester

HalloSchwester
Posts: 10
Joined: 11 Nov 2009, 11:15

28 Jan 2011, 12:18

Ok, a short update. If everything has been loaded once, it does not need to be loaded again. So I've made sure that everything is "cached" in the Java code and I'm down to 9 seconds time for loading stuff. Is there some kind of lazy switch?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests