私は primeFaces 3.4.2 を使用しており、並べ替え、フィルタリングを使用して Lazy Loading Data Table を実装しています。上記のデータテーブル内に別のデータテーブルを埋め込もうとしています。
上記の目的で、行拡張と行トグルを使用しました。
私のシーンはこのようなものです
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 の dataTable を表示したい (データがリストに存在する場合)。行トグル
3. TypeA と TypeB のリストを追跡するために customerDetails クラスを維持しています。このクラスを削除して、リストを Customer クラス自体に貼り付けますか?
// TypeB の場合も同様に、0 個または 1 個の TypeA リストを持つことができます。Customer Details クラスでは、
設計が正しくない場合は助けてください。これを機能させるために、いくつかのポインタを提供してください。