繁体   English   中英

JSF / Primefaces dataTable和排序问题

[英]JSF / Primefaces dataTable and sorting issue

我正在使用带有JSF 2.0.3的PrimeFaces 2.2。

我有一个xhtml视图,其中包含以下数据表:

<p:dataTable id="fooTable" 
    widgetVar="fooTable" 
    rowKey="#{foo.id}" 
    var="foo" 
    value="#{fooQueue.foos}"
    styleClass="table" 
    selection="#{fooQueue.selectedfoo}" 
    filteredValue="#{fooQueue.filteredfoos}"
    paginatorPosition="bottom" 
    paginatorAlwaysVisible="true" 
    selectionMode="single"
    rowEditListener="#{fooQueue.save}" 
    paginator="true" 
    rows="10" 
    rowIndexVar="#{foo.id}"
    emptyMessage="No foos found with given criteria" 
    rowStyleClass="#{foo.status == const.submitted ? 'gray' : null}"
    onRowSelectUpdate=":form:deleteValidation">

        <p:column id="mothersName" filterBy="#{foo.header1}"  filterMatchMode="contains">
            <f:facet name="header">
                <h:outputText value="Mother's Name" styleClass="tableHeader2" />
            </f:facet>

            <p:commandLink action="#{fooQueue.next(foo)}" 
                ajax="false" 
                disabled="#{foo.status == const.submitted || foo.id == 0}">
                <f:setPropertyActionListener value="#{foo}" target="#{fooQueue.selectedfoo}" />  
                <h:outputText value="#{foo.header1}" styleClass="tableData" />
            </p:commandLink>
        </p:column>

        <p:column sortBy="#{foo.header4}" >
            <f:facet name="header">
                <h:outputText value="DOB" styleClass="tableHeader2" style="width: 400px" />
            </f:facet>
            <h:outputText value="#{foo.header4}" styleClass="#{(foo.overSevenDays and foo.status != const.submitted and foo.id != 0)?'tableDataRed':'tableData'}" />
        </p:column></p:dataTable>

..具有以下辅助bean:


@ViewScoped
@ManagedBean
public class FooQueue extends BaseViewBean { 

    private List foos;
    private Foo selectedFoo;
    private List filterdFoos;

    public FooQueue() {
        logger.debug("Creating new FooRegQueue");
        retrieveFooRecords();
    }

    private void retrieveFooRecords(){
        foos = new ArrayList();
        foos.addAll(fooService.getAllFoos());
    }

    public String next(Foo clickedFoo) {        
        System.out.println(clickedFoo.getId());     
        return "";
    }

    public Collection getFoos() {
        return foos;
    }

    public Foo getSelectedFoo() {
        return selectedFoo;
    }

    public void setSelectedFoo(Foo foo) {
        if (foo != null) {
            this.selectedFoo = foo;
        }
    }

    public void setFilterdFoos(List filterdFoos) {
        this.filterdFoos = filterdFoos;
    }

    public List getFilterdFoos() {
        return filterdFoos;
    }
}

请注意母亲的姓名列上的“ commandLink”,以及DOB列上的“ sortBy”。

我遇到了一个奇怪的问题,似乎仅限于IE,如果我按DOB对数据进行排序,然后分页到最后一页并单击表中最后一条记录的commandLink,则会触发两个动作事件。 第一个事件正确报告我单击了排序表中的最后一条记录。 但是next()方法的第二次调用是针对UNsorted表中的最后一条记录。

谁能识别出我的xhtml或备用bean有什么问题? 这是已知的PrimeFaces问题吗? 已知的IE问题?

我正在使用IE 8进行测试。

我解决了 我只需要更改此:

<p:commandLink action="#{fooQueue.next(foo)}" 
  ajax="false" 
  disabled="#{foo.status == const.submitted || foo.id == 0}">
   <f:setPropertyActionListener value="#{foo}" target="#{fooQueue.selectedfoo}" />  
   <h:outputText value="#{foo.header1}" styleClass="tableData" />
</p:commandLink>

对此:

<p:commandLink action="#{fooQueue.next(foo)}" 
  ajax="true" 
  disabled="#{foo.status == const.submitted || foo.id == 0}">
   <f:setPropertyActionListener value="#{foo}" target="#{fooQueue.selectedfoo}" />  
   <h:outputText value="#{foo.header1}" styleClass="tableData" />
</p:commandLink>

注意ajax =“ true” 因为先前已将其设置为ajax =“ false”,所以它正在实例化我的后备bean的新实例,并且正在加载按默认排序顺序选择的行。 现在,它不会实例化新实例,并且我加载了单击的实际记录。

暂无
暂无

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

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