int count = 0;
int start = currentPage * resultPerPage;
for (int i = start ; (i < start + resultPerPage) && (i < searchResults.getList().size() ); i++) {
ResultDocument document = searchResults.getList().get(i);
ResultController ctrl = searchUIFactory.createController(ureq, getWindowControl(), mainForm, document);
ctrl.setHighlight(highlight);
listenTo(ctrl);
flc.add("result_" + ++count, ctrl.getInitialFormItem());
resultsCtrl.add(ctrl);
}
flc.contextPut("numOfResults", count);
flc.contextPut("results", resultsCtrl);
flc.contextPut("hasResult", results != null);