简体   繁体   中英

JSF2/Primefaces dataTable header sorting issue

I am using JSF 2 / Primefaces 3.5. I have a datatable which shows a list of data. The first column has a hyperlink and it shows the details of that record. I have a strange problem, if I do sorting the order changes from ascending to descending as expected. However the hyperlink pass the old id before sorting and opens the wrong details.

My code looks as below

Page:-

<p:dataTable id="rejectedRecords" var="institution"
            value="#{rejectedBean.institutions}" paginator="true" rows="15"
            sortMode="multiple" rowsPerPageTemplate="15,50,100,150,200">

            <p:column headerText="#{label.institutionName}"
                sortBy="#{institution.firmName}" width="40%"
                style="font-size:13px; color:black; text-align:left">
                <h:commandLink value="#{institution.firmName}"
                    action="#{rejectedBean.viewCreditInstitutionAction(institution.institutionId)}"
                    style="font-size:12px; color:#003399">
                </h:commandLink>
            </p:column>

            <p:column headerText="ID">
                <h:outputText value="#{institution.institutionId}" />
            </p:column>
</p:dataTable>

JSF Bean:-

public String viewCreditInstitutionAction(long institutionId) {
    System.out.println("ID arg :: " + institutionId);
            <...more code here...>
    return "details";
}               

After leaving this issue open for some time.... now we found out that this issue was caused due to the scope of that bean.

Earlier we had it in REQUEST scope its now changed to VIEW scope and this has solved the problem.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM