Q:

Primefaces datatable, sorting messes up submitted parameters

I have the following datatable:
<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>

and the corresponding method in the controller:
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;
}

The sorting itself works, but when I vreate the sortorder, the button:
<p:commandButton icon="ui-icon-closethick" action="#{fileManagementController.archiveFile(file.fullPath)}" 
                                             update="manageFilesForm:fileTable, growl" alt="Delete" title="Delete"/>

submits a wrong path, I can't see a pattern there, it just seems to randomly submit one. I had equals() overriden, but the same behaviour occurs when I override it with all attributes considers as well as when I do not override it at all. If I do not sort the table, it works as intended.  Any suggestions? Thanks in advance!

A:

The Bean was RequestScoped. chenged it to ViewScoped, works. Thanks to @Geinmachi.

