我已经在<p:dataTable>
上应用了全局过滤,但这根本不起作用。在Bean中调用getter,但根据搜索没有更新<p:dataTable>
。
代码是:
<p:dialog id="searchStdentsDlg" header="Search Students" widgetVar="srchStdents" modal="true">
<h:form id="searchStdentsFrm">
<p:dataTable id="srchStdentsTble"
var="student"
value="#{viewStudentsBean.studentsList}"
widgetVar="srchStdentTbl"
emptyMessage="No students found with the given criteria"
filteredValue="#{viewStudentsBean.filteredStudents}">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search Students:" />
<p:inputText id="globalFilterStdents" onkeyup="PF('srchStdentTbl').filter()" style="width:200px" placeholder="Enter keyword"/>
</p:outputPanel>
</f:facet>
<p:column id="stdentId" headerText="Id" filterBy="#{student.id}" filterStyle="display:none">
<h:outputText value="#{student.id}" />
</p:column>
<p:column id="stdentFirstName" headerText="Firstname" filterBy="#{student.firstName}" filterStyle="display:none">
<h:outputText value="#{student.firstName}" />
</p:column>
<p:column id="stdentLastname" headerText="Lastname" filterBy="#{student.lastName}" filterStyle="display:none">
<h:outputText value="#{student.lastName}" />
</p:column>
<p:column id="stdentFathername" headerText="Father name" filterBy="#{student.fatherName}" filterStyle="display:none">
<h:outputText value="#{student.fatherName}" />
</p:column>
<p:column id="stdentGender" headerText="Gender" filterBy="#{student.gender}" filterStyle="display:none">
<h:outputText value="#{student.gender}" />
</p:column>
<p:column id="stdentDOB" headerText="Date Of birth" filterBy="#{student.dob}" filterStyle="display:none">
<h:outputText value="#{student.dob}" />
</p:column>
<p:column id="stdentSkype" headerText="Skype/Email" filterBy="#{student.skypeOrEmailId}" filterStyle="display:none">
<h:outputText value="#{student.skypeOrEmailId}" />
</p:column>
<p:column id="stdentPhone" headerText="Phone No" filterBy="#{student.phoneNumber}" filterStyle="display:none">
<h:outputText value="#{student.phoneNumber}" />
</p:column>
<p:column id="stdentAddrs" headerText="Address" filterBy="#{student.address}" filterStyle="display:none">
<h:outputText value="#{student.address}" />
</p:column>
<p:column id="stdentCountry" headerText="Country" filterBy="#{student.country}" filterStyle="display:none">
<h:outputText value="#{student.country}" />
</p:column>
<p:column id="stdentJOD" headerText="Joining Date" filterBy="#{student.dateOfJoining}" filterStyle="display:none">
<h:outputText value="#{student.dateOfJoining}" />
</p:column>
<p:column id="stdentGenralRmrks" headerText="General Remarks" filterBy="#{student.generalRemarks}" filterStyle="display:none">
<h:outputText value="#{student.generalRemarks}" />
</p:column>
</p:dataTable>
</h:form>
</p:dialog>
我有另一个数据表,其中Global Filtering工作得非常好。 该代码是:
<p:dialog id="searchTchrsDlg" header="Search Teachers" widgetVar="srchTchrs" modal="true">
<h:form id="searchTchrsFrm">
<p:dataTable id="srchTechrsTble"
var="teacher"
value="#{viewTeachersBean.teachersList}"
widgetVar="srchTchrsTbl"
emptyMessage="No Teachers found with the given criteria"
filteredValue="#{viewTeachersBean.filteredTeachers}">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search Teachers:" />
<p:inputText id="globalFilter" onkeyup="PF('srchTchrsTbl').filter()" style="width:200px" placeholder="Enter keyword"/>
</p:outputPanel>
</f:facet>
<p:column headerText="Id" filterBy="#{teacher.id}" filterStyle="display:none">
<h:outputText value="#{teacher.id}" />
</p:column>
<p:column headerText="Firstname" filterBy="#{teacher.firstName}" filterStyle="display:none">
<h:outputText value="#{teacher.firstName}" />
</p:column>
<p:column headerText="Lastname" filterBy="#{teacher.lastName}" filterStyle="display:none">
<h:outputText value="#{teacher.lastName}" />
</p:column>
<p:column headerText="Contact No" filterBy="#{teacher.contactNo}" filterStyle="display:none">
<h:outputText value="#{teacher.contactNo}" />
</p:column>
<p:column headerText="Address" filterBy="#{teacher.address}" filterStyle="display:none">
<h:outputText value="#{teacher.address}" />
</p:column>
<p:column headerText="Joining Date" filterBy="#{teacher.joiningDate}" filterStyle="display:none">
<h:outputText value="#{teacher.joiningDate}" />
</p:column>
<p:column headerText="Qualification" filterBy="#{teacher.qualification}" filterStyle="display:none">
<h:outputText value="#{teacher.qualification}" />
</p:column>
<p:column headerText="Subjects" filterBy="#{teacher.subjects}" filterStyle="display:none">
<h:outputText value="#{teacher.subjects}" />
</p:column>
<p:column headerText="Languages" filterBy="#{teacher.languagesProficiency}" filterStyle="display:none">
<h:outputText value="#{teacher.languagesProficiency}" />
</p:column>
<p:column headerText="Total Exp" filterBy="#{teacher.totalExperience}" filterStyle="display:none">
<h:outputText value="#{teacher.totalExperience}" />
</p:column>
<p:column headerText="Salary" filterBy="#{teacher.salary}" filterStyle="display:none">
<h:outputText value="#{teacher.salary}" />
</p:column>
<p:column headerText="Total Leaves" filterBy="#{teacher.totalLeavesLimit}" filterStyle="display:none">
<h:outputText value="#{teacher.totalLeavesLimit}" />
</p:column>
</p:dataTable>
</h:form>
</p:dialog>
我正在使用PrimeFaces 5.0和JSF 2.2
PS:服务器端没有例外,浏览器控制台没有错误。
我非常感谢任何帮助。谢谢。