更新数据表bean后,数据表过滤器不起作用

时间:2017-10-05 13:14:20

标签: jsf primefaces datatable

DataTable列表过滤器在正常时间正常工作,但如果我单击active / inactive / all按钮,则数据表过滤器不起作用。在搜索字段中写入计数器1之后,该表只显示活动计数器1.但是当我单击不活动/所有按钮未刷新显示非活动列表时。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head></h:head>
<h:body>
        <ui:define name="body">
            <h:form id="form">
                <p:growl id="growl"/>
                <p:commandButton value="New" action="#{sdcController.newCounter}"/>
                <h:selectOneRadio value="#{sdcListController.rdoChk}" onchange="submit()"
                                  valueChangeListener="#{sdcListController.activeInactiveStateChanged}">
                    <f:selectItem itemValue="1" itemLabel="Active" />
                    <f:selectItem itemValue="0" itemLabel="Inactive" />
                    <f:selectItem itemValue="-1" itemLabel="All" />
                </h:selectOneRadio>
                <p:dataTable id="sdcList" var="sdc" value="#{sdcListController.sdcBeanList}" 
                             rows="15" paginator="true" 
                             rowIndexVar="row"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                             paginatorPosition="bottom"
                             widgetVar="counterListTable"
                             >
                    <f:facet name="header">
                        <p:outputPanel style="margin-left: 80%;  height: 7px;">
                            <h:outputText value="Search:" />
                            <p:inputText id="globalFilter" onkeyup="PF('counterListTable').filter()" />
                        </p:outputPanel>
                        SDC/Counter Management
                    </f:facet>
                    <p:column headerText="Counter Status" width="15%" filterBy="#{sdc.counterStatus}" filterStyle="display:none; visibility:hidden;">
                        <h:outputText value="#{sdc.counterStatus}" style="vertical-align: middle;padding-top: 4px"/>
                    </p:column>
                </p:dataTable>
            </h:form>
        </ui:define>
    </ui:composition>
</h:body>

以上代码为.xhtml文件

@ManagedBean
@RequestScoped
public class SdcListController {

private List<SdcBean> sdcBeanList;
private int rdoChk;

@ManagedProperty(value = "#{sdcServiceLayer}")
private SdcServiceLayer sdcServiceLayer;

private int sessionScId;

@ManagedProperty(value = "#{param.counterId}")
private int counterId;

@ManagedProperty(value = "#{param.scId}")
private int scId;


@PostConstruct
public void init() {
    Map<String, Object> sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
    sessionScId = QpaUtilities.strToIntDefaultZero(sessionMap.get("sessionScId").toString());
    rdoChk = QpaUtilities.strToIntDefaultM999(QpaUtilities.nullToEmptyString(sessionMap.get("sdcRdoChk")));
    rdoChk = (rdoChk == -999) ? 1 : rdoChk;
    initPageList(rdoChk);
}

private void initPageList(int state) {
    sdcBeanList = sdcServiceLayer.getAllSDCListForSearch(sessionScId, state);
    //rdoChk = "1";
}

public void activeInactiveStateChanged(ValueChangeEvent e) {
    rdoChk = QpaUtilities.strToIntDefaultZero(e.getNewValue().toString());
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("sdcRdoChk", rdoChk);

    initPageList(rdoChk);
}

public List<SdcBean> getSdcBeanList() {
    return sdcBeanList;
}


public void setSdcBeanList(List<SdcBean> sdcBeanList) {
    this.sdcBeanList = sdcBeanList;
}

public void setRdoChk(int rdoChk) {
    this.rdoChk = rdoChk;
}

public int getRdoChk() {
    return rdoChk;
}



}

上面的代码是sdcListController.java文件 enter image description here

0 个答案:

没有答案