状态有一个下拉列表,应根据该下拉列表更改数据表中的记录。我在页面选择的分页中还有另一个下拉列表。 当分页的下拉菜单发生变化时,将进行ajax调用,该调用将转到bean并获取结果并更新数据表。每页显示10条记录。
问题是,当我选择一个有30条记录的州,然后从分页的下拉菜单中选择第二页时,它可以正常工作, 但是如果我选择另一个只有7条记录的州,然后从分页的下拉菜单中选择第二页 然后数据表变成空白,并且之后ajax也停止工作。
代码如下:
<div align="left" style="width:99%">
<!-- PAGING CODE - START -->
<rich:datascroller align="top" fastControls="hide" for="data"
maxPages="15"
page="#{courtSessionBean.pageNo}" reRender="sc2" id="sc1"
actionListener="#{courtSessionBean.scrollEvent}"
rendered="#{courtSessionBean.totalPages > 1}">
<%@include file="/jsp/include/NavigationControls.jsp" %>
<f:facet name="pages">
<h:panelGroup>
<x:dataList itemStyleClass="odd" style="odd" var="page"
value="#{courtSessionBean.pageList}">
<h:commandLink action="#{courtSessionBean.search}"
rendered="#{pagingView.currentPageNo!=page}">
<h:outputText value="#{page}"></h:outputText>
<f:param name="PAGE_NO" value="#{page}"></f:param>
<f:param name="orderBy"
value="#{courtSessionBean.orderBy}"></f:param>
<f:param name="orderType"
value="#{courtSessionBean.orderType}"></f:param>
</h:commandLink>
<h:outputText value="#{page}" rendered="#{pagingView.currentPageNo==page}"></h:outputText>
<h:outputText value=" " />
</x:dataList>
<h:outputText value=" Page " />
<h:selectOneMenu value="#{courtSessionBean.pageNo}">
<a4j:support reRender="sc1,sc2,data" event="onchange" actionListener="#{courtSessionBean.search}"></a4j:support>
<f:selectItems value="#{courtSessionBean.pages}" />
</h:selectOneMenu>
<h:outputText value=" / #{courtSessionBean.totalPages}" />
<h:outputText value=" " />
</h:panelGroup>
</f:facet>
</rich:datascroller>
<!-- PAGING CODE - END -->
</div>
<div style="width:99%">
<x:dataTable width="100%" rowClasses="even,odd" styleClass="table" first="0"
rows="10" cellpadding="0" cellspacing="0" id="data" value="#
{courtSessionBean.tableModel}" binding="#{courtSessionBean.table}"
var="sessionheader">
<h:column rendered="#{courtSessionBean.orderType=='ASC' &&
courtSessionBean.orderBy=='CSH.AGENCYNAME'}" >
<f:facet name="header">
<h:commandLink action="#{courtSessionBean.search}">
<h:graphicImage url="#
{facesContext.externalContext.requestContextPath}/../images/sort_asc.gif" />
<f:param name="orderType" value="DESC"></f:param>
<f:param name="orderBy" value="CSH.AGENCYNAME"></f:param>
<f:param name="PAGE_NO" value="#{courtSessionBean.pageNo}">
</f:param>
<h:outputText value="#{bundle.courtsession_agency}"
escape="false"/>
</h:commandLink>
</f:facet>
<h:outputText value="#{sessionheader.agencyName}" />
</h:column>
</x:dataTable>
</div>
<div style="width:99%">
<x:dataTable width="100%" rowClasses="even,odd" styleClass="table" first="0" rows="10" cellpadding="0" cellspacing="0" id="data" value="#{courtSessionBean.tableModel}" binding="#{courtSessionBean.table}" var="sessionheader">
<h:column rendered="#{courtSessionBean.orderType=='ASC' && courtSessionBean.orderBy=='CSH.AGENCYNAME'}" >
<f:facet name="header">
<h:commandLink action="#{courtSessionBean.search}">
<h:graphicImage url="#{facesContext.externalContext.requestContextPath}/../images/sort_asc.gif" />
<f:param name="orderType" value="DESC"></f:param>
<f:param name="orderBy" value="CSH.AGENCYNAME"></f:param>
<f:param name="PAGE_NO" value="#{courtSessionBean.pageNo}"></f:param>
<h:outputText value="#{bundle.courtsession_agency}" escape="false"/>
</h:commandLink>
</f:facet>
<h:outputText value="#{sessionheader.agencyName}" />
</h:column>
</x:dataTable>
</div>
<!-- PAGING CODE - START -->
<div align="left" style="width:99%">
<rich:datascroller align="top" for="data" maxPages="15" page="#{courtSessionBean.pageNo}" reRender="sc1" fastControls="hide"
id="sc2" actionListener="#{courtSessionBean.scrollEvent}" rendered="#{courtSessionBean.totalPages > 1}">
<%@include file="/jsp/include/NavigationControls.jsp" %>
<f:facet name="pages">
<h:panelGroup>
<x:dataList itemStyleClass="odd" style="odd" var="page" value="#{courtSessionBean.pageList}">
<h:commandLink action="#{courtSessionBean.search}" rendered="#{pagingView.currentPageNo!=page}">
<h:outputText value="#{page}"></h:outputText>
<f:param name="PAGE_NO" value="#{page}"></f:param>
<f:param name="orderBy" value="#{courtSessionBean.orderBy}"></f:param>
<f:param name="orderType" value="#{courtSessionBean.orderType}"></f:param>
</h:commandLink>
<h:outputText value="#{page}" rendered="#{pagingView.currentPageNo==page}"></h:outputText>
<h:outputText value=" " />
</x:dataList>
</h:panelGroup>
</f:facet>
</rich:datascroller>
<!-- PAGING CODE - END -->
<f:subview id="noRecordFound" rendered="#{courtSessionBean.totalRows==0}">
<div class="odd" style="width:100%" align="center">
<b><h:outputText value="#{bundle.note_noRecordsFound}" /></b>
</div>
</f:subview>
</div>