我正在使用 primeFaces 3.4.2 并实现了带有排序、过滤的延迟加载数据表。我正在尝试在上述数据表中嵌入另一个数据表。
为了上述目的,我使用了行扩展和行切换器。
我的场景是这样的
public class Customer {
@Id
private Long id;
private String name;
private String email;
@JoinColumn(unique = true, name = "Cust_Details_Id" )
@OneToOne(cascade = CascadeType.ALL)
private CustomerDetails customerDetails;
}
public class CustomerDetails {
@Id
private Long cdId;
@OneToOne(mappedBy = "customerDetails", cascade = CascadeType.ALL)
private Customer customer;
@OneToMany(mappedBy = "customerDetails", cascade = CascadeType.ALL)
private List<TypeA> listOfTypeA = new ArrayList<TypeA>();
@OneToMany(mappedBy = "customerDetails", cascade = CascadeType.ALL)
private List<TypeB> listOfTypeB = new ArrayList<TypeB>();;
}
public classTypeA {
@Id
private Long typeAId;
@ManyToOne(cascade = CascadeType.ALL)
private MeasurementDetails measurementDetails;
// Around 10-12 fields to store its details
}
public classTypeB {
@Id
private Long typeBId;
@ManyToOne(cascade = CascadeType.ALL)
private MeasurementDetails measurementDetails;
// Around 12-15 fields to store its details
}
//我正在使用 LazyLoading 如下代码
<p:dataTable id="dataTable"
var="customer"
value="#{customerController.lazyModel}"
styleClass="userDataTableStyle"
paginator="true"
rows="10"
selection="#{customerController.selctedCustomers}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
lazy="true"
rowsPerPageTemplate="10,15,50" >
<f:facet name="header">Customer List</f:facet>
<p:column> <p:rowToggler id="rowToggler" /> </p:column>
<p:column selectionMode="multiple" style="width:18px" />
<p:column headerText="First Name" sortBy="#{customer.firstName}" filterBy="#{customer.firstName}">
<f:facet name="header"> <p:outputLabel value="First Name" /> </f:facet>
<p:commandLink value="#{customer.firstName}" update=":customerDetailForm:display" oncomplete="custDialog.show()" title="View">
<f:setPropertyActionListener value="#{customer}" target="#{customerController.selectedCustomer}" />
</p:commandLink>
</p:column>
<!-- Other Columns -->
<!-- I want to embed another data here but based on the previous selected customers row Toggle -->
<p:rowExpansion id="expand" rendered="true" >
<p:dataTable id="dataTableInner"
var="cust"
value="#{customerController.selctedCustomers}"
styleClass="userDataTableStyle"
lazy="true" rowsPerPageTemplate="10,15,50">
<f:facet name="header"> Customer Details </f:facet>
<p:column headerText="Customer Details " sortBy="#{customer.customerDetails}" >
<f:facet name="header">
<p:outputLabel value="Customer Details" />
</f:facet>
<p:outputLabel value="#{customer.customerDetails.customerId}" />
</p:column>
<p:column headerText="Mas ccc" >
<f:facet name="header">
<p:outputLabel value="Date" />
</f:facet>
<p:outputLabel value="#{customer.customerDetails.TypeA[0]}" /> <!-- Example -->
</p:column>
</p:dataTable> <!-- Inner datatable -->
</p:rowExpansion>
</p:dataTable> <!-- Outer datatable -->
问题
1. 我如何知道哪个客户已被“行切换”而不是通过我用于删除的复选框
2. 我想显示 TypeA 和 TypeB 的数据表(如果列表中存在数据),它会被触发行切换
器 3. 我正在维护 customerDetails 类来跟踪 TypeA 和 TypeB 的列表,我应该删除这个类并将列表简单地粘贴到 Customer 类本身吗?
// 它可以有零个或一个 TypeA 列表,对于 TypeB 也类似,在客户详细信息类中,
如果我的设计不正确,请帮助我并提供一些指针,以便我可以让它工作