1
我有以下数据表:Primefaces的数据表,整理弄乱了提交参数
<p:dataTable var="file" value="#{fileManagementController.storedFiles}"
styleClass="right-aligned" emptyMessage="No files found" id="fileTable" sortBy="#{fileManagementController.sortOrder}">
<p:column headerText="Scenario" sortBy="#{file.scenario}" id="scenario">
<h:outputText value="#{file.scenario}"/>
</p:column>
<p:column headerText="File Type" sortBy="#{file.fileType}" id="type">
<h:outputText value="#{file.fileType}"/>
</p:column>
<p:column headerText="Affiliated Month" sortBy="#{file.affiliatedMonth}" id="affiliatedMonth">
<h:outputText value="#{fileManagementController.convertAffiliationMonthForDisplayInTable(file.affiliatedMonth)}"/>
</p:column>
<p:column headerText="Creation Date" sortBy="#{file.creationDate}" id="sreationDate">
<h:outputText value="#{fileManagementController.convertDateForDisplayInTable(file.creationDate)}"/>
</p:column>
<p:column headerText="Last changed/Uploaded" sortBy="#{file.uploadDate}">
<h:outputText value="#{fileManagementController.convertTimestampForDisplayInTable(file.uploadDate)}"/>
</p:column>
<p:column headerText="Size" sortBy="#{file.sizeInByte}">
<h:outputText value="#{fileManagementController.roundToOneDecimal(file.sizeInByte/1024)} kB"/>
</p:column>
<p:column headerText="Actions" styleClass="centered">
<p:commandButton icon="ui-icon-pencil" action="#{fileManagementController.editFileContent(file)}" alt="Edit" title="Edit"/>
<p:commandButton icon="ui-icon-closethick" action="#{fileManagementController.archiveFile(file.fullPath)}"
update="manageFilesForm:fileTable, growl" alt="Delete" title="Delete"/>
</p:column>
</p:dataTable>
,并在控制器的相应方法:
public List<SortMeta> getSortOrder() {
UIViewRoot view = FacesContext.getCurrentInstance().getViewRoot();
DataTable table = (DataTable) view.findComponent(":manageFilesForm:fileTable");
List<SortMeta> preSortOrder = new ArrayList();
SortMeta sm1 = createSortMeta(table, 0, "scenario");
SortMeta sm2 = createSortMeta(table, 1, "type");
SortMeta sm3 = createSortMeta(table, 2, "affiliatedMonth");
preSortOrder.add(sm1);
preSortOrder.add(sm2);
preSortOrder.add(sm3);
LOG.debug("Created sortOrder for File Table; ordered by {} and {}", sm1.getSortField(), sm2.getSortField());
return preSortOrder;
}
排序本身的工作,但是当我vreate的排序顺序,按钮:
<p:commandButton icon="ui-icon-closethick" action="#{fileManagementController.archiveFile(file.fullPath)}"
update="manageFilesForm:fileTable, growl" alt="Delete" title="Delete"/>
提交一个错误的路径,我看不到一个模式,它只是似乎随机提交一个。我有equals()重写,但是当我覆盖所有属性时,以及当我不重写它时,会发生同样的行为。如果我不对表格进行排序,它会按预期工作。有什么建议么?提前致谢!
您正在使用哪个版本的PF?也许你需要强制排序事件的ajax更新。
在:http://stackoverflow.com/questions/23761333/primefaces-datatable-row-select-not-work-after-filtering-或排序 – Yamada你的bean至少是'@ ViewScoped'吗? – Geinmachi