I am developing pagination logic using JSF1.2 and in the process I have 4 links for first, previous, next and last pages corresponding to the results. I enter the search criteria in the Search page and click submit to get some records. I have a view link corresponding to each of the records to see the complete details. So I have two Managed beans one for Search/pagination functionality and other for View complete record details.
Whats the problem then?
When I search for the records the pagination works completely fine. However when I view the details of a record and come back to search page, I find that every time I click the next button the next() method is getting called twice.
Is there any solution for this?
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);
}
}