【发布时间】:2012-12-31 09:48:23
【问题描述】:
我正在使用 JSF1.2 开发分页逻辑,在此过程中,我有 4 个链接,分别对应于结果的第一页、上一页、下一页和最后一页。我在“搜索”页面中输入搜索条件,然后单击“提交”以获取一些记录。我有一个与每条记录对应的查看链接,可以查看完整的详细信息。所以我有两个托管 bean,一个用于搜索/分页功能,另一个用于查看完整的记录详细信息。
那有什么问题呢?
当我搜索记录时,分页工作完全正常。但是,当我查看记录的详细信息并返回搜索页面时,我发现每次单击下一步按钮时,next() 方法都会被调用两次。
有什么解决办法吗?
The code is as follows:-
Inside search:-
<h:commandLink value="#{msg['heading.nextLink']}"
binding="#{searchRoutesForView.nextLink}"
actionListener="#{searchRoutesForView.next}">
</h:commandLink>
Inside SearchManagedbean:-
public void next(ActionEvent actionEvent) {
if ((pointer + noOfRecordsToBeDisplayed) >= readConfig.length) {
readRoutingResponse.setReadConfig(Arrays.copyOfRange(readConfig,
pointer, readConfig.length));
pointer = readConfig.length;
System.out.println("pointer inside next =" + pointer);
setOrDisableLinks(false, false, true, true);
} else {
readRoutingResponse.setReadConfig(Arrays.copyOfRange(readConfig,
pointer, pointer + noOfRecordsToBeDisplayed));
pointer += noOfRecordsToBeDisplayed;
System.out.println("pointer inside next -- else =" + pointer);
setOrDisableLinks(false, false, false, false);
}
}
【问题讨论】:
-
您能从您的 xhtml 中显示更多代码吗?特别是如果您的 h:commandLink 周围有一个条件,并且您的 searchRoutesForView 在哪个范围内