简体   繁体   English

JSF2 / Primefaces dataTable标头排序问题

[英]JSF2/Primefaces dataTable header sorting issue

I am using JSF 2 / Primefaces 3.5. 我正在使用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. 但是,超链接在排序之前传递旧ID并打开错误的详细信息。

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:- 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. 离开这个问题一段时间后......现在我们发现这个问题是由于该bean的范围引起的。

Earlier we had it in REQUEST scope its now changed to VIEW scope and this has solved the problem. 之前我们在REQUEST范围内将它改为VIEW范围,这解决了这个问题。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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