我正在使用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.我如何知道哪个客户是“Row Toggeled”而不是通过我用于删除的Checkbox
2.我想显示TypeA和TypeB的dataTable(如果数据存在于列表中),它会在行转换器上被触发。
3.我正在维护customerDetails类以跟踪TypeA和TypeB的列表,
我可以删除这个类,只需将列表粘贴到客户类中吗?
//在客户明细类中,它可以有零或一个TypeA列表,类似于TypeB 如果我的设计不正确,请帮助我,并提供一些指示,以便我可以使其工作