我有一个带全局过滤的数据表。我想过滤数据。在搜索条件中,我基于未过滤数据按下了一个键,并且 Ajax 调用不会被终止仍然加载。我犯了错误请建议我。
这是我的代码:
<p:dataTable id="dataCall" var="calls" value="#{calllist.mediumCallsModel}" style="font-size: 12px; width: 1000px" widgetVar="callsTable"
emptyMessage="No record found with given criteria"
selection="#{calllist.selectedCall}" selectionMode="single" rows="5" paginator="true" filteredValue="#{callList.filteredDatas}"
paginatorPosition="bottom" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >
<p:ajax event="rowSelect" listener="#{calllist.onRowSelect}" update=":MyListForm:showlist: :MyListForm:growl" />
<p:ajax event="rowUnselect" listener="#{calllist.onRowUnselect}" update=":MyListForm:growl"/>
<f:facet name="header">
<p:outputPanel style="display:block; text-align:right">
<h:outputText value="Search all fields:"/>
<p:inputText id="globalFilter" onkeyup="callsTable.filter()" style="width:150px" />
</p:outputPanel>
</f:facet>
<p:column headerText="Call ID" filterBy="#{calls.callId}" sortBy="#{calls.callId}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.callId}" />
</p:column>
<p:column headerText="Created By" filterBy="#{calls.createdBy}" sortBy="#{calls.createdBy}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.createdBy}" />
</p:column>
<p:column headerText="Location" filterBy="#{calls.location}" sortBy="#{calls.location}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.location}" />
</p:column>
<p:column headerText="Status" filterBy="#{calls.status}" sortBy="#{calls.status}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.status}" />
</p:column>
<p:column headerText="Product" filterBy="#{calls.product}" sortBy="#{calls.product}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.product}" />
</p:column>
<p:column headerText="Module" filterBy="#{calls.module}" sortBy="#{calls.module}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.module}" />
</p:column>
<p:column headerText="Group Assigned" filterBy="#{calls.groupAssigned}" sortBy="#{calls.groupAssigned}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.groupAssigned}" />
</p:column>
<p:column headerText="Assigned to" filterBy="#{calls.assignedTo}" sortBy="#{calls.assignedTo}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.assignedTo}" />
</p:column>
<p:column headerText="Call creation" filterBy="#{calls.callCreation}" sortBy="#{calls.callCreation}" filterStyle="display: none; visibility: hidden;">
<h:outputText value="#{calls.callCreation}" />
</p:column>
</p:dataTable>
我的豆子:
public class CallList{
private List<CallModel> callList = null;
private CallModel selectedCall = new CallModel();
private CallDataModel mediumCallsModel;
private List<CallModel> filteredDatas;
private boolean enableButton;
public CallList() {
this.enableButton = true;
}
public CallModel getSelectedCall() {
return selectedCall;
}
public void setSelectedCall(CallModel selectedCall) {
this.selectedCall = selectedCall;
}
public CallDataModel getMediumCallsModel() {
getAllList();
return mediumCallsModel;
}
public void setMediumCallsModel(CallDataModel mediumCallsModel) {
this.mediumCallsModel = mediumCallsModel;
}
public List<CallModel> getCallList() {
return callList;
}
public void setCallList(List<CallModel> callList) {
this.callList = callList;
}
public List<CallModel> getFilteredDatas() {
return filteredDatas;
}
public void setFilteredDatas(List<CallModel> filteredDatas) {
this.filteredDatas = filteredDatas;
}
public List<CallModel> getAllList() {
List<CallHeader> headerList = null;
List<ProductMaster> productList = null;
List<StatusMaster> statusList = null;
List<ModuleMaster> moduleDesc = null;
List<Time> timeList = null;
List<PriorityMaster> priorityList = null;
List<SlaMaster> slaList = null;
List<SubmoduleMaster> subList = null;
List<UserMaster> userList=null;
Session ses = HibernateUtil.getSessionFactory().openSession();
FacesContext context = FacesContext.getCurrentInstance();
try {
HttpSession sess = (HttpSession) context.getExternalContext().getSession(true);
String userid = (String) sess.getAttribute("userId");
headerList = ses.createCriteria(CallHeader.class).add(Expression.or(Restrictions.eq("userMaster.userId", userid), Restrictions.eq("assignedId", userid))).list();
callList = new ArrayList<CallModel>(headerList.size());
for (Iterator<CallHeader> it = headerList.iterator(); it.hasNext();) {
CallHeader callHeader = it.next();
productList = ses.createCriteria(ProductMaster.class).add(Restrictions.eq("productId", callHeader.getId().getProductId())).list();
Iterator<ProductMaster> it1 = productList.iterator();
ProductMaster productMaster = it1.next();
statusList = ses.createCriteria(StatusMaster.class).add(Restrictions.eq("id.statusId", callHeader.getStatusId())).list();
Iterator<StatusMaster> it2 = statusList.iterator();
it2.hasNext();
StatusMaster statusMaster = it2.next();
moduleDesc = ses.createCriteria(ModuleMaster.class).add(Restrictions.eq("id.moduleId", callHeader.getModuleId())).list();
Iterator<ModuleMaster> it3 = moduleDesc.iterator();
it3.hasNext();
ModuleMaster moduleMaster = it3.next();
timeList = ses.createCriteria(Time.class).add(Restrictions.eq("id.callId", callHeader.getId().getCallId())).list();
Iterator<Time> it4 = timeList.iterator();
it4.hasNext();
Time time = it4.next();
priorityList = ses.createCriteria(PriorityMaster.class).add(Restrictions.eq("id.priorityId", callHeader.getPriorityId())).list();
Iterator<PriorityMaster> it5 = priorityList.iterator();
it5.hasNext();
PriorityMaster priorityMaster = it5.next();
slaList = ses.createCriteria(SlaMaster.class).add(Restrictions.eq("id.slaId", callHeader.getSlaId())).list();
Iterator<SlaMaster> it6 = slaList.iterator();
it6.hasNext();
SlaMaster slaMaster = it6.next();
subList = ses.createCriteria(SubmoduleMaster.class).add(Restrictions.eq("id.productId", callHeader.getId().getProductId())).add(Restrictions.eq("id.moduleId", callHeader.getModuleId())).list();
Iterator<SubmoduleMaster> it7 = subList.iterator();
it7.hasNext();
SubmoduleMaster subMaster = it7.next();
userList=ses.createCriteria(UserMaster.class).add(Restrictions.eq("userId", callHeader.getAssignedId())).list();
Iterator<UserMaster> it8 = userList.iterator();
it8.hasNext();
UserMaster userMaster = it8.next();
callList.add(new CallModel(callHeader.getId().getCallId(), callHeader.getUserMaster().getFirstName() + " " + callHeader.getUserMaster().getLastName(), callHeader.getUserMaster().getLocation(), statusMaster.getStatusDesc(), productMaster.getProductName(), moduleMaster.getModuleDesc(), callHeader.getGroupMaster().getGroupId(), userMaster.getUserId(), time.getCallCreated(),
priorityMaster.getId().getPriorityId(), callHeader.getProposedTime(), callHeader.getAcceptedTime(), callHeader.getActualTime(), callHeader.getCallRelation(), slaMaster.getId().getSlaId(), statusMaster.getId().getStatusId(), productMaster.getProductId(), moduleMaster.getId().getModuleId(), subMaster.getId().getSubmoduleId(), callHeader.getProblemType(),
callHeader.getRatingId(), callHeader.getId().getCompanyId(),userMaster.getFirstName()+" "+userMaster.getLastName()));
}
mediumCallsModel = new CallDataModel(callList);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
ses.close();
}
return callList;
}
public void onRowSelect(SelectEvent event) { }
}