ОБНОВЛЕНО
У меня есть следующая таблица данных:
<p:dataTable id="shipOwnerCompanyHistoriesTable" widgetVar="shipOwnerCompanyHistoriesTable" var="entry" value="#{shipRegisterView.ship.shipOwnerCompanyHistories}" rowKey="#{entry}" selectionMode="single" selection="#{shipRegisterView.selectedShipOwnerCompanyHistory}"
styleClass="margin-bottom-10" paginator="true" rows="5"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10" emptyMessage="Δεν βρέθηκαν εγγραφές.">
<p:ajax event="rowSelect" update="@form" listener="#{shipRegisterView.selectShipOwnerCompanyHistory}" />
<p:ajax event="rowUnselect" update="@form" listener="#{shipRegisterView.unselectShipOwnerCompanyHistory}" />
<p:column headerText="Πλοιοκτησία">
<h:outputText value="#{entry.company.brandNameGreek} / #{entry.company.brandNameLatin}"/>
</p:column>
<p:column headerText="Από" sortBy="#{entry.fromDate}">
<h:outputText value="#{entry.fromDate}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Έως" sortBy="#{entry.toDate}">
<h:outputText value="#{entry.toDate}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Ποσοστό" sortBy="#{entry.percentage}">
<h:outputText value="#{entry.percentage}%"/>
</p:column>
<p:column headerText="Σημειώσεις">
<h:outputText value="#{entry.comments}" rendered="#{entry.comments != null and not empty entry.comments}"/>
<h:outputText value="-" rendered="#{entry.comments == null or empty entry.comments}"/>
</p:column>
</p:dataTable>
Со значением, взятым из следующего класса представления, например:
public ShipRegisterView() {
newFlagHistory = new ShipFlagHistory();
lossState = "";
growlId = "shipMessages";
ship = new Ship();
ship.setLossState("Normal");
shipList = new ArrayList<Ship>();
newEncumbrance = new ShipEncumbrance();
newFek = new ShipFek();
newShipEngine = new ShipEngine();
newShipRenameHistory = new ShipRenameHistory();
newTransferHistory = new ShipTransferHistory();
newShipOwnerCompanyHistory = new ShipOwnerCompanyHistory();
newShipOwnerNaturalPersonHistory = new ShipOwnerNaturalPersonHistory();
newShipAdminCompanyHistory = new ShipAdminCompanyHistory();
newShipUtilizationCompanyHistory = new ShipUtilizationCompanyHistory();
newShipOwnerCompanyHistory.setCompany(new Company());
newShipOwnerNaturalPersonHistory.setNaturalPerson(new NaturalPerson());
newShipAdminCompanyHistory.setCompany(new Company());
newShipUtilizationCompanyHistory.setCompany(new Company());
newConditionHistory = new ShipConditionHistory();
newRecreationalLicense = new RecreationalLicense();
newRecreationalLicense.setAdminClassAct(new AdminClassAct());
newRecreationalLicense.setAdminDeclassAct(new AdminDeclassAct());
searchInspectionsList = new ArrayList<Inspection>();
searchCertificatesList = new ArrayList<Certificate>();
searchRosCertificatesList = new ArrayList<Certificate>();
searchAffirmationsList = new ArrayList<Affirmation>();
newNaturalPerson = new NaturalPerson();
newNaturalPerson.setAddress(new Address());
searchNaturalPerson = new NaturalPerson();
harboursForShipsForDNPUser = new ArrayList<Harbour>();
fines = new ArrayList<Fine>();
complaints = new ArrayList<Complaint>();
completedRoutes = new ArrayList<CompletedRoute>();
searchOwnerCompany = new SearchCompany();
searchOwnerNaturalPerson = new SearchNaturalPerson();
searchAdminCompany = new SearchCompany();
searchUtilizationCompany = new SearchCompany();
ship.setShipEngines(new HashSet<ShipEngine>());
ship.setShipAdminCompanyHistories(new HashSet<ShipAdminCompanyHistory>());
ship.setShipOwnerCompanyHistories(new HashSet<ShipOwnerCompanyHistory>());
ship.setShipOwnerNaturalPersonHistories(new HashSet<ShipOwnerNaturalPersonHistory>());
ship.setShipUtilizationCompanyHistories(new HashSet<ShipUtilizationCompanyHistory>());
ship.setShipEncumbrances(new HashSet<ShipEncumbrance>());
ship.setShipConditionHistories(new ArrayList<ShipConditionHistory>());
ship.setShipFeks(new HashSet<ShipFek>());
ship.setDocuments(new HashSet<AccompanyingFile>());
ship.setShipPhotos(new HashSet<ShipPhoto>());
ship.setShipFlagHistories(new HashSet<ShipFlagHistory>());
ship.setRecreationalLicenses(new HashSet<RecreationalLicense>());
ship.setShipTransferHistories(new HashSet<ShipTransferHistory>());
ship.setLossTheftDecisions(new HashSet<LossTheftDecision>());
ship.setShipRenameHistories(new HashSet<ShipRenameHistory>());
List<ShipOwnerCompanyHistory> list = new ArrayList<>(shipOwnerCompanyHistories);
};
Я пытаюсь отсортировать столбцы таблицы с помощью атрибута sortBy
простых шрифтов. При нажатии на столбец на веб-странице появляется следующая ошибка: введите описание изображения здесь
И на моем коте:
ERROR (com.liferay.faces.bridge.context.internal.ExceptionHandlerAjaxImpl. java: 71) .handle - Тип данных должен быть java .util.List или javax.faces.model.ListDataModel, чтобы его можно было сортировать.
Теперь я понимаю, что это должен быть список, чтобы работать, но есть ли способ, где я могу отсортировать таблицу? Отображение гибернации тоже set
:
<set name="shipOwnerCompanyHistories" inverse="true" cascade="all-delete-orphan" lazy="false" >
<key column="shipId" on-delete="cascade"/>
<one-to-many class="gr.yptp.hcg.sr.Model.ShipOwnerCompanyHistory"/>
</set>
Сообщите мне. Я очень ценю вашу помощь.